こんにちは!アプリケーションが異なる言語をサポートしている場合は、ローカリゼーションに関連する問題が発生した可能性があります:キーの書き込みエラー、言語の値の欠落、緊急の翻訳編集の場合にアプリケーションを再構築する必要性。開発の最も楽しい瞬間ではありませんか?
この記事では、Vivid.Moneyでのローカリゼーションの仕組みについて説明します。ローカリゼーション用に選択したツール、発生した問題、およびそれらがどのように解決されたかについて説明します。
プロジェクトの詳細をよりよく理解するために、この資料を読むことができます。さらに苦労せずにこの記事を開始することをお勧めします。
どのローカリゼーション方法を選択しましたか
ローカリゼーションの要件には、次の点が含まれます。
信頼できる唯一の情報源のためのプラットフォーム(iOS、Android、バックエンド)間の同期。
コンパイル中に使用されたキーの正しいスペルをチェックして、キー名にタイプミスをする可能性を排除します。
開発者が機能を実装するために必要なことを行うためにより多くの時間を費やすために、開発者が異なる言語のローカリゼーションを独自に導入する必要はありません。
翻訳者とのやりとりのしやすさ。
アプリケーションを再構築せずにキー値を変更する機能。
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!