New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

github.com/bleeding182/localization

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/bleeding182/localization

  • v0.0.0-20180502192337-1a5e7288cb55
  • Source
  • Go
  • Socket score

Version published
Created
Source

Localization Util

A util to export localized strings from Google Sheets to the xml (Android) or strings (iOS) format.

Example

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

Usage

Create a new Google Sheet with the following columns: key, value, android, ios, comment and fill in your translations.

keyvalueandroidioscomment
app_nameLocalization Utilapp 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)
    }
}
Longer Names

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

Plurals are supported with the __pl_[<one|other|etc>] suffix and generate <plural> on Android and a LocalizableGen.stringsdict on iOS.

Localization

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

Package last updated on 02 May 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc