Skip to content

Commit

Permalink
Update:Editor config/vscode settings/prettierrc
Browse files Browse the repository at this point in the history
  • Loading branch information
advplyr committed Jun 16, 2024
1 parent c52a60f commit e79d099
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 38 deletions.
7 changes: 1 addition & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
trim_trailing_whitespace = true
17 changes: 17 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 400,
"proseWrap": "never",
"trailingComma": "none",
"overrides": [
{
"files": ["*.html"],
"options": {
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
}
}
]
}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"octref.vetur"
]
}
27 changes: 27 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"vetur.format.defaultFormatterOptions": {
"prettier": {
"semi": false,
"singleQuote": true,
"printWidth": 400,
"proseWrap": "never",
"trailingComma": "none"
},
"prettyhtml": {
"printWidth": 400,
"singleQuote": false,
"wrapAttributes": false,
"sortAttributes": false
}
},
"editor.formatOnSave": true,
"editor.detectIndentation": true,
"editor.tabSize": 2,
"javascript.format.semicolons": "remove",
"[javascript][json][jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "octref.vetur"
}
}
64 changes: 32 additions & 32 deletions plugins/i18n.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,41 @@
import Vue from "vue"
import Vue from 'vue'
import enUsStrings from '../strings/en-us.json'

const defaultCode = 'en-us'
let $localStore = null

const languageCodeMap = {
'cs': { label: 'Čeština', dateFnsLocale: 'cs' },
'da': { label: 'Dansk', dateFnsLocale: 'da' },
'de': { label: 'Deutsch', dateFnsLocale: 'de' },
cs: { label: 'Čeština', dateFnsLocale: 'cs' },
da: { label: 'Dansk', dateFnsLocale: 'da' },
de: { label: 'Deutsch', dateFnsLocale: 'de' },
'en-us': { label: 'English', dateFnsLocale: 'enUS' },
'es': { label: 'Español', dateFnsLocale: 'es' },
'fi': { label: 'Suomi', dateFnsLocale: 'fi' },
'fr': { label: 'Français', dateFnsLocale: 'fr' },
'hr': { label: 'Hrvatski', dateFnsLocale: 'hr' },
'it': { label: 'Italiano', dateFnsLocale: 'it' },
'lt': { label: 'Lietuvių', dateFnsLocale: 'lt' },
'hu': { label: 'Magyar', dateFnsLocale: 'hu' },
'nl': { label: 'Nederlands', dateFnsLocale: 'nl' },
'no': { label: 'Norsk', dateFnsLocale: 'no' },
'pl': { label: 'Polski', dateFnsLocale: 'pl' },
es: { label: 'Español', dateFnsLocale: 'es' },
fi: { label: 'Suomi', dateFnsLocale: 'fi' },
fr: { label: 'Français', dateFnsLocale: 'fr' },
hr: { label: 'Hrvatski', dateFnsLocale: 'hr' },
it: { label: 'Italiano', dateFnsLocale: 'it' },
lt: { label: 'Lietuvių', dateFnsLocale: 'lt' },
hu: { label: 'Magyar', dateFnsLocale: 'hu' },
nl: { label: 'Nederlands', dateFnsLocale: 'nl' },
no: { label: 'Norsk', dateFnsLocale: 'no' },
pl: { label: 'Polski', dateFnsLocale: 'pl' },
'pt-br': { label: 'Português (Brasil)', dateFnsLocale: 'ptBR' },
'ru': { label: 'Русский', dateFnsLocale: 'ru' },
'sv': { label: 'Svenska', dateFnsLocale: 'sv' },
'uk': { label: 'Українська', dateFnsLocale: 'uk' },
ru: { label: 'Русский', dateFnsLocale: 'ru' },
sv: { label: 'Svenska', dateFnsLocale: 'sv' },
uk: { label: 'Українська', dateFnsLocale: 'uk' },
'vi-vn': { label: 'Tiếng Việt', dateFnsLocale: 'vi' },
'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'zhCN' },
'zh-cn': { label: '简体中文 (Simplified Chinese)', dateFnsLocale: 'zhCN' }
}

function supplant(str, subs) {
// source: http://crockford.com/javascript/remedial.html
return str.replace(/{([^{}]*)}/g,
function (a, b) {
var r = subs[b]
return typeof r === 'string' || typeof r === 'number' ? r : a
}
)
return str.replace(/{([^{}]*)}/g, function (a, b) {
var r = subs[b]
return typeof r === 'string' || typeof r === 'number' ? r : a
})
}

Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map(code => {
Vue.prototype.$languageCodeOptions = Object.keys(languageCodeMap).map((code) => {
return {
text: languageCodeMap[code].label,
value: code
Expand Down Expand Up @@ -67,12 +65,14 @@ var translations = {

function loadTranslationStrings(code) {
return new Promise((resolve) => {
import(`../strings/${code}`).then((fileContents) => {
resolve(fileContents.default)
}).catch((error) => {
console.error('Failed to load i18n strings', code, error)
resolve(null)
})
import(`../strings/${code}`)
.then((fileContents) => {
resolve(fileContents.default)
})
.catch((error) => {
console.error('Failed to load i18n strings', code, error)
resolve(null)
})
})
}

Expand All @@ -83,7 +83,7 @@ async function loadi18n(code) {
return false
}

const strings = translations[code] || await loadTranslationStrings(code)
const strings = translations[code] || (await loadTranslationStrings(code))
if (!strings) {
console.warn(`Invalid lang code ${code}`)
return false
Expand Down

0 comments on commit e79d099

Please sign in to comment.