feat(settings): add alpha and beta language sections

closes: #6662
This commit is contained in:
Patryk Osmaczko 2022-07-28 19:52:19 +02:00 committed by osmaczko
parent 8e31303c6d
commit 43de90e80e
6 changed files with 90 additions and 38 deletions

View File

@ -1,15 +1,19 @@
import locale_table
type
Item* = object
locale: string
name: string
native: string
flag: string # unicode emoji
state: locale_table.State
proc initItem*(locale, name, native, flag: string): Item =
proc initItem*(locale, name, native, flag: string, state: locale_table.State): Item =
result.locale = locale
result.name = name
result.native = native
result.flag = flag
result.state = state
proc locale*(self: Item): string {.inline.} =
self.locale
@ -22,3 +26,6 @@ proc native*(self: Item): string {.inline.} =
proc flag*(self: Item): string {.inline.} =
self.flag
proc state*(self: Item): locale_table.State {.inline.} =
self.state

View File

@ -1,44 +1,50 @@
import tables
type
State* {.pure.} = enum
Alpha # 30-90% translations done
Beta # >90% translations done
Stable # >90% translations done and reviewed
Description* = object
name*: string
native*: string
flag*: string
state*: State
let localeDescriptionTable* = {
"ar": Description(name: "Arabic", native: "العربية", flag: ""),
"bn": Description(name: "Bengali", native: "বাংলা", flag: "X"),
"de": Description(name: "German", native: "Deutsch", flag: "🇩🇪"),
"el": Description(name: "Greek", native: "Ελληνικά", flag: "🇬🇷"),
"en": Description(name: "English", native: "English", flag: "🏴󠁧󠁢󠁥󠁮󠁧󠁿"),
"en_US": Description(name: "English (United States)", native: "English (United States)", flag: "🇺🇸"),
"es": Description(name: "Spanish", native: "Español", flag: "🇪🇸"),
"es_419": Description(name: "Spanish (Latin America)", native: "Español (Latinoamerica)", flag: ""),
"es_AR": Description(name: "Spanish (Argentina)", native: "Español (Argentina)", flag: "🇦🇷"),
"fa": Description(name: "Persian", native: "فارسی", flag: "🇮🇷"),
"fr": Description(name: "French", native: "Français", flag: "🇫🇷"),
"he": Description(name: "Hebrew", native: "עברית'", flag: "🇮🇱"),
"hi": Description(name: "Hindi", native: "हिन्दी", flag: "🇮🇳"),
"hu": Description(name: "Hungarian", native: "Magyar", flag: "🇭🇺"),
"id": Description(name: "Indonesian", native: "Bahasa Indonesia", flag: "🇮🇩"),
"it": Description(name: "Italian", native: "Italiano", flag: "🇮🇹"),
"ja": Description(name: "Japanese", native: "日本語", flag: "🇯🇵"),
"ko": Description(name: "Korean", native: "한국어", flag: "🇰🇷"),
"ms": Description(name: "Malay", native: "Bahasa Melayu", flag: "🇲🇾"),
"ne": Description(name: "Nepali", native: "नेपाली", flag: "🇳🇵"),
"nl": Description(name: "Dutch", native: "Nederlands", flag: "🇳🇱"),
"pl": Description(name: "Polish", native: "Polski", flag: "🇵🇱"),
"pt": Description(name: "Portuguese", native: "Português", flag: "🇵🇹"),
"pt_BR": Description(name: "Portuguese (Brazil)", native: "Português (Brasil)", flag: "🇧🇷"),
"ru": Description(name: "Russian", native: "Русский", flag: "🇷🇺"),
"sv": Description(name: "Swedish", native: "Svenska", flag: "🇸🇪"),
"th": Description(name: "Thai", native: "ไทย / Phasa Thai", flag: "🇹🇭"),
"tl": Description(name: "Tagalog", native: "Tagalog", flag: "🇵🇭"),
"tr": Description(name: "Turkish", native: "Türkçe", flag: "🇹🇷"),
"ug": Description(name: "Uyghur", native: "Uyƣurqə / ئۇيغۇرچە", flag: "X"),
"uk": Description(name: "Ukrainian", native: "Українська", flag: "🇺🇦"),
"vi": Description(name: "Vietnamese", native: "Việtnam", flag: "🇻🇳"),
"zh_CN": Description(name: "Chinese (China)", native: "中文(中國)", flag: "🇨🇳"),
"zh_TW": Description(name: "Chinese (Taiwan)", native: "中文(台灣)", flag: "🇹🇼"),
"ar": Description(name: "Arabic", native: "العربية", flag: "", state: State.Alpha),
"bn": Description(name: "Bengali", native: "বাংলা", flag: "X", state: State.Alpha),
"de": Description(name: "German", native: "Deutsch", flag: "🇩🇪", state: State.Alpha),
"el": Description(name: "Greek", native: "Ελληνικά", flag: "🇬🇷", state: State.Alpha),
"en": Description(name: "English", native: "English", flag: "🏴󠁧󠁢󠁥󠁮󠁧󠁿", state: State.Stable),
"en_US": Description(name: "English (United States)", native: "English (United States)", flag: "🇺🇸", state: State.Alpha),
"es": Description(name: "Spanish", native: "Español", flag: "🇪🇸", state: State.Alpha),
"es_419": Description(name: "Spanish (Latin America)", native: "Español (Latinoamerica)", flag: "", state: State.Alpha),
"es_AR": Description(name: "Spanish (Argentina)", native: "Español (Argentina)", flag: "🇦🇷", state: State.Alpha),
"fa": Description(name: "Persian", native: "فارسی", flag: "🇮🇷", state: State.Alpha),
"fr": Description(name: "French", native: "Français", flag: "🇫🇷", state: State.Alpha),
"he": Description(name: "Hebrew", native: "עברית'", flag: "🇮🇱", state: State.Alpha),
"hi": Description(name: "Hindi", native: "हिन्दी", flag: "🇮🇳", state: State.Alpha),
"hu": Description(name: "Hungarian", native: "Magyar", flag: "🇭🇺", state: State.Alpha),
"id": Description(name: "Indonesian", native: "Bahasa Indonesia", flag: "🇮🇩", state: State.Alpha),
"it": Description(name: "Italian", native: "Italiano", flag: "🇮🇹", state: State.Alpha),
"ja": Description(name: "Japanese", native: "日本語", flag: "🇯🇵", state: State.Alpha),
"ko": Description(name: "Korean", native: "한국어", flag: "🇰🇷", state: State.Alpha),
"ms": Description(name: "Malay", native: "Bahasa Melayu", flag: "🇲🇾", state: State.Alpha),
"ne": Description(name: "Nepali", native: "नेपाली", flag: "🇳🇵", state: State.Alpha),
"nl": Description(name: "Dutch", native: "Nederlands", flag: "🇳🇱", state: State.Alpha),
"pl": Description(name: "Polish", native: "Polski", flag: "🇵🇱", state: State.Alpha),
"pt": Description(name: "Portuguese", native: "Português", flag: "🇵🇹", state: State.Alpha),
"pt_BR": Description(name: "Portuguese (Brazil)", native: "Português (Brasil)", flag: "🇧🇷", state: State.Alpha),
"ru": Description(name: "Russian", native: "Русский", flag: "🇷🇺", state: State.Alpha),
"sv": Description(name: "Swedish", native: "Svenska", flag: "🇸🇪", state: State.Alpha),
"th": Description(name: "Thai", native: "ไทย / Phasa Thai", flag: "🇹🇭", state: State.Alpha),
"tl": Description(name: "Tagalog", native: "Tagalog", flag: "🇵🇭", state: State.Alpha),
"tr": Description(name: "Turkish", native: "Türkçe", flag: "🇹🇷", state: State.Alpha),
"ug": Description(name: "Uyghur", native: "Uyƣurqə / ئۇيغۇرچە", flag: "X", state: State.Alpha),
"uk": Description(name: "Ukrainian", native: "Українська", flag: "🇺🇦", state: State.Alpha),
"vi": Description(name: "Vietnamese", native: "Việtnam", flag: "🇻🇳", state: State.Alpha),
"zh_CN": Description(name: "Chinese (China)", native: "中文(中國)", flag: "🇨🇳", state: State.Alpha),
"zh_TW": Description(name: "Chinese (Taiwan)", native: "中文(台灣)", flag: "🇹🇼", state: State.Alpha),
}.toTable()

View File

@ -8,6 +8,7 @@ type
Name
Native
Flag
State
QtObject:
type
@ -39,6 +40,7 @@ QtObject:
ModelRole.Name.int: "name",
ModelRole.Native.int: "native",
ModelRole.Flag.int: "flag",
ModelRole.State.int: "state",
}.toTable
method data(self: Model, index: QModelIndex, role: int): QVariant =
@ -60,3 +62,5 @@ QtObject:
result = newQVariant(item.native)
of ModelRole.Flag:
result = newQVariant(item.flag)
of ModelRole.State:
result = newQVariant(item.state.int)

View File

@ -36,7 +36,8 @@ proc populateLanguageModel(self: Module) =
locale = locale,
name = localeDescr.name,
native = localeDescr.native,
flag = localeDescr.flag
flag = localeDescr.flag,
state = localeDescr.state
))
else:
warn "missing locale details", locale

View File

@ -104,6 +104,12 @@ SettingsContentBase {
property string newKey
function descriptionForState(state) {
if (state == Constants.translationsState.alpha) return qsTr("Alpha languages")
if (state == Constants.translationsState.beta) return qsTr("Beta languages")
return ""
}
Timer {
id: languagePause
interval: 100
@ -113,14 +119,36 @@ SettingsContentBase {
}
}
inputList: root.languageStore.languageModel
inputList: SortFilterProxyModel {
sourceModel: root.languageStore.languageModel
// !Don't use proxy roles cause they harm performance a lot!
// "category" is the only role that can't be mocked by StatusListPicker::proxy
// due to StatusListPicker internal implementation limitation (ListView's section.property)
proxyRoles: [
ExpressionRole {
name: "category"
expression: languagePicker.descriptionForState(model.state)
}
]
sorters: [
RoleSorter {
roleName: "state"
sortOrder: Qt.DescendingOrder
},
StringSorter {
roleName: "name"
}
]
}
proxy {
key: (model) => model.locale
name: (model) => model.name
shortName: (model) => model.native
symbol: (model) => ""
imageSource: (model) => StatusQUtils.Emoji.iconSource(model.flag)
category: (model) => ""
selected: (model) => model.locale === root.languageStore.currentLanguage
setSelected: (model, val) => null // readonly
}

View File

@ -248,6 +248,12 @@ QtObject {
readonly property int moreThanFiveMins: 4
}
readonly property QtObject translationsState: QtObject {
readonly property int alpha: 0
readonly property int beta: 1
readonly property int stable: 2
}
readonly property int communityImported: 0
readonly property int communityImportingInProgress: 1
readonly property int communityImportingError: 2