mirror of
https://github.com/ichmagmaus111/ghostgram.git
synced 2026-07-10 01:48:35 +02:00
Update Ghostgram features
This commit is contained in:
@@ -106,7 +106,8 @@ func _internal_getCountriesList(accountManager: AccountManager<TelegramAccountMa
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<[Country], NoError> in
|
||||
switch result {
|
||||
case let .countriesList(apiCountries, hash):
|
||||
case let .countriesList(countriesListData):
|
||||
let (apiCountries, hash) = (countriesListData.countries, countriesListData.hash)
|
||||
let result = apiCountries.compactMap { Country(apiCountry: $0) }
|
||||
if result == current {
|
||||
return .complete()
|
||||
@@ -145,7 +146,8 @@ func _internal_getCountriesList(accountManager: AccountManager<TelegramAccountMa
|
||||
extension Country.CountryCode {
|
||||
init(apiCountryCode: Api.help.CountryCode) {
|
||||
switch apiCountryCode {
|
||||
case let .countryCode(_, countryCode, apiPrefixes, apiPatterns):
|
||||
case let .countryCode(countryCodeData):
|
||||
let (countryCode, apiPrefixes, apiPatterns) = (countryCodeData.countryCode, countryCodeData.prefixes, countryCodeData.patterns)
|
||||
let prefixes: [String] = apiPrefixes.flatMap { $0 } ?? []
|
||||
let patterns: [String] = apiPatterns.flatMap { $0 } ?? []
|
||||
self.init(code: countryCode, prefixes: prefixes, patterns: patterns)
|
||||
@@ -156,7 +158,8 @@ extension Country.CountryCode {
|
||||
extension Country {
|
||||
init(apiCountry: Api.help.Country) {
|
||||
switch apiCountry {
|
||||
case let .country(flags, iso2, defaultName, name, countryCodes):
|
||||
case let .country(countryData):
|
||||
let (flags, iso2, defaultName, name, countryCodes) = (countryData.flags, countryData.iso2, countryData.defaultName, countryData.name, countryData.countryCodes)
|
||||
self.init(id: iso2, name: defaultName, localizedName: name, countryCodes: countryCodes.map { Country.CountryCode(apiCountryCode: $0) }, hidden: (flags & 1 << 0) != 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import TelegramApi
|
||||
extension LocalizationInfo {
|
||||
init(apiLanguage: Api.LangPackLanguage) {
|
||||
switch apiLanguage {
|
||||
case let .langPackLanguage(flags, name, nativeName, langCode, baseLangCode, pluralCode, stringsCount, translatedCount, translationsUrl):
|
||||
case let .langPackLanguage(langPackLanguageData):
|
||||
let (flags, name, nativeName, langCode, baseLangCode, pluralCode, stringsCount, translatedCount, translationsUrl) = (langPackLanguageData.flags, langPackLanguageData.name, langPackLanguageData.nativeName, langPackLanguageData.langCode, langPackLanguageData.baseLangCode, langPackLanguageData.pluralCode, langPackLanguageData.stringsCount, langPackLanguageData.translatedCount, langPackLanguageData.translationsUrl)
|
||||
self.init(languageCode: langCode, baseLanguageCode: baseLangCode, customPluralizationCode: pluralCode, title: name, localizedTitle: nativeName, isOfficial: (flags & (1 << 0)) != 0, totalStringCount: stringsCount, translatedStringCount: translatedCount, platformUrl: translationsUrl)
|
||||
}
|
||||
}
|
||||
@@ -24,3 +25,18 @@ public final class SuggestedLocalizationInfo {
|
||||
self.availableLocalizations = availableLocalizations
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Swiftgram
|
||||
// All the languages are "official" to prevent their deletion
|
||||
public let SGLocalizations: [LocalizationInfo] = [
|
||||
LocalizationInfo(languageCode: "zhcncc", baseLanguageCode: "zh-hans-raw", customPluralizationCode: "zh", title: "Chinese (Simplified) zhcncc", localizedTitle: "简体中文 (聪聪) - 已更完", isOfficial: true, totalStringCount: 7160, translatedStringCount: 7144, platformUrl: "https://translations.telegram.org/zhcncc/"),
|
||||
LocalizationInfo(languageCode: "taiwan", baseLanguageCode: "zh-hant-raw", customPluralizationCode: "zh", title: "Chinese (zh-Hant-TW) @zh_Hant_TW", localizedTitle: "正體中文", isOfficial: true, totalStringCount: 7160, translatedStringCount: 3761, platformUrl: "https://translations.telegram.org/taiwan/"),
|
||||
LocalizationInfo(languageCode: "hongkong", baseLanguageCode: "zh-hant-raw", customPluralizationCode: "zh", title: "Chinese (Hong Kong)", localizedTitle: "中文(香港)", isOfficial: true, totalStringCount: 7358, translatedStringCount: 6083, platformUrl: "https://translations.telegram.org/hongkong/"),
|
||||
// TODO(swiftgram): Japanese beta
|
||||
// baseLanguageCode is actually nil, since it's an "official" beta language
|
||||
LocalizationInfo(languageCode: "vi-raw", baseLanguageCode: "vi-raw", customPluralizationCode: "vi", title: "Vietnamese", localizedTitle: "Tiếng Việt (beta)", isOfficial: true, totalStringCount: 7160, translatedStringCount: 3795, platformUrl: "https://translations.telegram.org/vi/"),
|
||||
LocalizationInfo(languageCode: "hi-raw", baseLanguageCode: "hi-raw", customPluralizationCode: "hi", title: "Hindi", localizedTitle: "हिन्दी (beta)", isOfficial: true, totalStringCount: 7358, translatedStringCount: 992, platformUrl: "https://translations.telegram.org/hi/"),
|
||||
LocalizationInfo(languageCode: "ja-raw", baseLanguageCode: "ja-raw", customPluralizationCode: "ja", title: "Japanese", localizedTitle: "日本語 (beta)", isOfficial: true, totalStringCount: 9697, translatedStringCount: 9683, platformUrl: "https://translations.telegram.org/ja/"),
|
||||
// baseLanguageCode should be changed to nil? or hy?
|
||||
LocalizationInfo(languageCode: "earmenian", baseLanguageCode: "earmenian", customPluralizationCode: "hy", title: "Armenian", localizedTitle: "Հայերեն", isOfficial: true, totalStringCount: 7358, translatedStringCount: 6384, platformUrl: "https://translations.telegram.org/earmenian/")
|
||||
]
|
||||
|
||||
@@ -8,7 +8,8 @@ func _internal_currentlySuggestedLocalization(network: Network, extractKeys: [St
|
||||
|> retryRequest
|
||||
|> mapToSignal { result -> Signal<SuggestedLocalizationInfo?, NoError> in
|
||||
switch result {
|
||||
case let .config(_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, suggestedLangCode, _, _, _, _):
|
||||
case let .config(configData):
|
||||
let suggestedLangCode = configData.suggestedLangCode
|
||||
if let suggestedLangCode = suggestedLangCode {
|
||||
return _internal_suggestedLocalizationInfo(network: network, languageCode: suggestedLangCode, extractKeys: extractKeys) |> map(Optional.init)
|
||||
} else {
|
||||
@@ -25,11 +26,14 @@ func _internal_suggestedLocalizationInfo(network: Network, languageCode: String,
|
||||
var entries: [LocalizationEntry] = []
|
||||
for string in strings {
|
||||
switch string {
|
||||
case let .langPackString(key, value):
|
||||
case let .langPackString(langPackStringData):
|
||||
let (key, value) = (langPackStringData.key, langPackStringData.value)
|
||||
entries.append(.string(key: key, value: value))
|
||||
case let .langPackStringPluralized(_, key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue):
|
||||
case let .langPackStringPluralized(langPackStringPluralizedData):
|
||||
let (key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue) = (langPackStringPluralizedData.key, langPackStringPluralizedData.zeroValue, langPackStringPluralizedData.oneValue, langPackStringPluralizedData.twoValue, langPackStringPluralizedData.fewValue, langPackStringPluralizedData.manyValue, langPackStringPluralizedData.otherValue)
|
||||
entries.append(.pluralizedString(key: key, zero: zeroValue, one: oneValue, two: twoValue, few: fewValue, many: manyValue, other: otherValue))
|
||||
case let .langPackStringDeleted(key):
|
||||
case let .langPackStringDeleted(langPackStringDeletedData):
|
||||
let (key) = (langPackStringDeletedData.key)
|
||||
entries.append(.string(key: key, value: ""))
|
||||
}
|
||||
}
|
||||
@@ -78,15 +82,19 @@ func _internal_downloadLocalization(network: Network, languageCode: String) -> S
|
||||
let version: Int32
|
||||
var entries: [LocalizationEntry] = []
|
||||
switch result {
|
||||
case let .langPackDifference(_, _, versionValue, strings):
|
||||
case let .langPackDifference(langPackDifferenceData):
|
||||
let (versionValue, strings) = (langPackDifferenceData.version, langPackDifferenceData.strings)
|
||||
version = versionValue
|
||||
for string in strings {
|
||||
switch string {
|
||||
case let .langPackString(key, value):
|
||||
case let .langPackString(langPackStringData):
|
||||
let (key, value) = (langPackStringData.key, langPackStringData.value)
|
||||
entries.append(.string(key: key, value: value))
|
||||
case let .langPackStringPluralized(_, key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue):
|
||||
case let .langPackStringPluralized(langPackStringPluralizedData):
|
||||
let (key, zeroValue, oneValue, twoValue, fewValue, manyValue, otherValue) = (langPackStringPluralizedData.key, langPackStringPluralizedData.zeroValue, langPackStringPluralizedData.oneValue, langPackStringPluralizedData.twoValue, langPackStringPluralizedData.fewValue, langPackStringPluralizedData.manyValue, langPackStringPluralizedData.otherValue)
|
||||
entries.append(.pluralizedString(key: key, zero: zeroValue, one: oneValue, two: twoValue, few: fewValue, many: manyValue, other: otherValue))
|
||||
case let .langPackStringDeleted(key):
|
||||
case let .langPackStringDeleted(langPackStringDeletedData):
|
||||
let (key) = (langPackStringDeletedData.key)
|
||||
entries.append(.string(key: key, value: ""))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user