Hallo! Wenn Ihre Anwendung verschiedene Sprachen unterstützt, sind wahrscheinlich Probleme im Zusammenhang mit der Lokalisierung aufgetreten: Fehler beim Schreiben von Schlüsseln, fehlende Werte für Sprachen, die Notwendigkeit, die Anwendung im Falle von Notübersetzungsänderungen neu zu erstellen. Nicht die angenehmsten Momente der Entwicklung, oder?
In diesem Artikel wird erläutert, wie die Lokalisierung in Vivid.Money funktioniert: Wir zeigen Ihnen, welches Tool für die Lokalisierung Sie ausgewählt haben, auf welche Probleme Sie gestoßen sind und wie sie gelöst wurden.
Zum besseren Verständnis der Besonderheiten des Projekts können Sie dieses Material lesen. Wir empfehlen, diesen Artikel ohne weiteres zu beginnen
Welche Lokalisierungsmethode haben Sie gewählt?
Unsere Lokalisierungsanforderungen umfassen die folgenden Punkte:
Synchronisation zwischen Plattformen (iOS, Android, Backend) für eine einzige Quelle der Wahrheit;
Überprüfen der korrekten Schreibweise der während der Kompilierung verwendeten Schlüssel, um die Möglichkeit eines Tippfehlers im Schlüsselnamen auszuschließen;
Entwickler müssen keine Lokalisierungen für verschiedene Sprachen unabhängig voneinander einführen, damit Entwickler mehr Zeit damit verbringen können, das zu tun, was sie sollten - um Funktionen zu implementieren.
Einfache Interaktion mit Übersetzern;
Die Möglichkeit, Schlüsselwerte zu ändern, ohne die Anwendung neu zu erstellen.
Apple .strings .stringsdict. .strings (“”: “”), . .stringsdict plural plist. , NSLocalizedString. Apple .
, : , , , . XLIFF ( , XML), . , - .
, , , . , , , :
|
|
Lokalise |
Phrase |
OneSky |
POEditor |
|
+ |
- |
- |
- |
|
+ |
+ |
- |
+ |
plural |
+ |
+ |
+/- |
+ |
SDK |
+ |
+ |
+ |
- |
|
+ |
- |
- |
- |
/ |
+ |
- |
- |
- |
|
+ |
- |
- |
- |
|
+ |
+/- |
- |
- |
|
|
|
|
https://www.oneskyapp.com/pricing/ |
|
Crowdin, . , - , . Lokalise, , . , , .
lokalise , , , . :
;
Fastlane, ;
API/CLI;
SDK.
, SDK. : , , SDK. , , .
API, Lokalise , . .
, Lokalise SDK, . : . , Lokalise SDK , , , .
(debug/release), .
.strings .stringsdict plutil (property list utility), : .. Ruby:
def self.valid_bundle?(path)
puts 'Validating localization bundle...'
strings = Dir["#{path}/Contents/Resources/*.lproj/*.strings"]
stringsdict = Dir["#{path}/Contents/Resources/*.lproj/*.stringsdict"]
is_valid = true
(strings + stringsdict).each do |path|
stdout, stderr, status = Open3.capture3("plutil -lint #{path}")
unless status.exitstatus == 0
is_valid = false
line = stderr.strip[/on line ([0-9]*)/, 1]
puts "***********************************************".red
puts "Found the invalid string in file at path: #{path}".red
puts "The invalid string: #{File.readlines(path)[line.to_i-1].strip}".red
end
end
puts "***********************************************".red unless is_valid
is_valid
end
Localisation, .
, - . LocalizationFetcher : . , , - . , , Documents, .
, , , Localise.bundle. : Documents .lproj Localizable.strings Localizable.stringsdict Localizable.nocache.strings Localizable.nocache.stringsdict, . “Localizable.nocache” tableName localizedString(forKey:value:table:) , .
, : , , , .
R.swift , .., -, , ( ), -, . .
: Localisation.swift , Localizable.strings Localizable.stringsdict .
?
:
public static let localization_var = "localization_key".localized
public static func localization_method(_ value1: String) -> String {
"localization_method_key".localized(with: value1)
}
localized :
var localized: String {
let localLocalisation = Self.localLocaliseBundle?.localizedString(
forKey: self,
value: nil,
table: nil
)
let serverLocalisation = Self.makeServerLocaliseBundle()?.localizedString(
forKey: self,
value: localLocalisation,
table: “Localizable.nocache”
)
return serverLocalisation ?? localLocalisation ?? self
}
;
, Documents, ;
, , , .
, (localized(with:)), :
func localized(with parameters: CVarArg...) -> String {
let correctLocalizedString: String = {
if localized.starts(with: "%#@") {
return localized
}
return localized
.replacingOccurrences(of: "%s", with: "%@")
.replacingOccurrences(
of: "(%[0-9])\\$s",
with: "$1@",
options: .regularExpression
)
}()
guard !correctLocalizedString.isEmpty else {
return self
}
return String(format: correctLocalizedString, arguments: parameters)
}
:
plural ;
, Lokalise, ;
, ;
, , .
: -, Localizable.stringsdict , ; -, , , plural . , localizedString(forKey:value:table:) plural , Localizable.stringsdict, __NSLocalizedString. plural . , .regularExpression replacingOccurencies(of:with:options:) String , , __NSLocalizedString.
, :
;
Lokalise , ;
, , , debug , Localisation.swift;
, , , ;
Lokalise;
, , production Lokalise , ;
production Lokalise;
.
production Lokalise Gitlab , , , , , .
, .
iOS Android
, , , iOS Android -. , iOS %@, Android %s. , , Android first Lokalise, iOS .
, - . , . . , .
, , .
, 2 “” - debug production. debug , , production - , debug production.
, , production . , - . : , Localisation.swift, . , , .
, Lokalise, - . , .
, , , debug production , . , , , .
, , - , . That’s all, Folks!