Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/bleeding182/localization
A util to export localized strings from Google Sheets to the xml (Android) or strings (iOS) format.
An example export of this sheet can be seen in the example folder, or you can try it yourself by running the following command, which will create an /exports
folder in your current directory.
[localization] --sheetID 1upHiDHWu5m30tYdhMDP4GXheOWUE4r3VrHfmAUXiuyI android
[localization] --sheetID 1upHiDHWu5m30tYdhMDP4GXheOWUE4r3VrHfmAUXiuyI ios
The example shows the
Create a new Google Sheet with the following columns: key, value, android, ios, comment
and fill in your translations.
key | value | android | ios | comment |
---|---|---|---|---|
app_name | Localization Util | app name |
Value is the default value for your string, but can be overridden per platform in the respective column. While the default value might get escaped or modified during the export, the platform column will be written as-is. Comments are just comments.
Copy the sheet id from the url (https://docs.google.com/spreadsheets/d/{{sheet_id}}/edit#gid=0
) and run the util to export your strings (default arguments will export to a /exports
folder)
[localization] --sheetID {{sheet_id}} [ios|android]
On Android this will result in a generated_strings.xml
with the following content:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<resources>
<!-- app name -->
<string name="app_name">Localization Util</string>
</resources>
While on iOS you get LocalizableGen.strings
/* app name */
"app_name" = "Localization Util";
Along with a swift helper file Strings.swift
public struct Strings {
public struct App {
static let Name = Strings.localized("app_name", value: "Localization Util", comment: "app name")
}
public static func localized(_ key: String, tableName: String? = nil, bundle: Bundle = Bundle.main, value: String, comment: String = "") -> String {
return NSLocalizedString(key, tableName: tableName, bundle: bundle, value: value, comment: comment)
}
}
Keys like base_app_name
can be supported for the iOS export by using 2 underscores __
to signal the end of the group name. base_app__name
will generate a struct BaseApp
for iOS.
Plurals are supported with the __pl_[<one|other|etc>]
suffix and generate <plural>
on Android and a LocalizableGen.stringsdict
on iOS.
Your base language should be in a default
sheet as you can see in the example and any translations should go into sheets with the appropriate name, e.g. de
. The tool will export the files in the correct folder structure.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.