Skip to content

Latest commit

 

History

History
140 lines (93 loc) · 4.33 KB

README.md

File metadata and controls

140 lines (93 loc) · 4.33 KB

poeditor-cli

Gem Build Status Codecov

Command line application for POEditor.

poeditor-cli

Features

  • 📚 Exporting translation files directly from POEditor to your project directory
  • 🎲 Mapping translation directory dynamically
  • 🍎 Replacing %s with %@ for Apple strings
  • 📦 We use it in our products

Installation

$ [sudo] gem install poeditor-cli

Usage

A single command will do almost everything for you.

$ poeditor pull

Before you do this, you have to create a poeditor.yml file. This is a configuration file for poeditor-cli. Here is an example poeditor.yml:

api_key: YOUR_API_KEY
project_id: PROJECT_ID
type: apple_strings
tags: [ios]

languages: [en, ko, ja, zh-Hans, zh-Hant, fr, es]
language_alias:
  zh: zh-Hans

path: Resources/{LANGUAGE}.lproj/Localizable.strings
path_replace:
  en: Resources/Base.lproj/Localizable.strings

See Example poeditor.yml files section for more examples.

  • api_key

    Your POEditor API key. You can check it on POEditor API Access. Use such like $MY_API_KEY to use environment variable.

  • project_id

    POEditor project ID. You can check this value on the web browser's address bar. (For example: https://poeditor.com/projects/view?id=XXXXX) Use such like $MY_PROJECT_ID to use environment variable.

  • languages

    Language codes to export. Use the language codes that your project uses. For example, use zh-Hans for Xcode project and zh-rCN for Android project even though POEditor uses zh-CN for simplified chinese.

  • language_alias (Optional)

    Specify this value to copy the translation file to another language. For example, zh is same with the translation of zh-Hans or zh-rCN. In this case, you can specify the language_alias value as follows:

    languages: [ko, ja, zh-Hans, zh-Hant]
    language_alias:
      zh: zh-Hans
  • path

    The path for translation files to be downloaded. Each values of languages will be used for filling {LANGUAGE} placeholder.

  • path_replace (Optional)

    Specify this value to enforce the translation file path. For example, Android uses values/strings.xml for default language and values-ko/strings.xml or values-ja/strings.xml for others. In this case, you can specify the path_replace as follows:

    path: myapp/src/main/res/values-{LANGUAGE}/strings.xml
    path_replace:
      en: myapp/src/main/res/values/strings.xml
  • type

    Translation file format. (po, pot, mo, xls, csv, resw, resx, android_strings, apple_strings, xliff, properties, key_value_json, json, xmb, xtb)

  • tags (Optional)

    Terms which contain whole tags will be exported. (&&)

Example poeditor.yml files

  • Xcode project

    api_key: $POEDITOR_API_KEY        # from envvar
    project_id: $POEDITOR_PROJECT_ID  # from envvar
    type: apple_strings
    tags: [ios]
    
    languages: [en, ko, ja, zh-Hans, zh-Hant]
    path: Resources/{LANGUAGE}.lproj/Localizable.strings
  • Android project

    api_key: $POEDITOR_API_KEY        # from envvar
    project_id: $POEDITOR_PROJECT_ID  # from envvar
    type: android_strings
    tags: [android]
    
    languages: [en, ko, ja, zh-rCN, zh-rTW]
    
    path: myapp/src/main/res/values-{LANGUAGE}/strings.xml
    path_replace:
      en: myapp/src/main/res/values/strings.xml
  • Projects using gettext

    api_key: $POEDITOR_API_KEY        # from envvar
    project_id: $POEDITOR_PROJECT_ID  # from envvar
    type: po
    
    languages: [en, ko, ja, zh_Hans, zh_Hant]
    language_alias:
      zh: zh_Hans
    
    path: myservice/translations/{LANGUAGE}/LC_MESSAGES/messages.po

License

poeditor-cli is written by Suyeol Jeon and available under MIT license.