Giter Club home page Giter Club logo

michaelhenry / localizr Goto Github PK

View Code? Open in Web Editor NEW
35.0 3.0 5.0 755 KB

Localizr is a Tool that handles and automates the generation of localization files for IOS and Android so there will be only one source of truth for all of your localization strings.

Home Page: http://localizr.iamkel.net

License: MIT License

Python 80.81% Shell 0.86% HTML 11.20% Ruby 6.78% Dockerfile 0.32% Procfile 0.03%
localization locale mobile ios android-application i18n translation android dsl fastlane

localizr's Introduction

Localizr

Build Status Twitter Docker Version

Localizr is a Tool that handles and automates localization files. Basically we give limited access to the translators to let them input or upload different keystrings and the developer will just fetch it on development or deployment only when if there is an update or changes. This will lessen or prevent the mistake that developer made because he/she has no clue what are those words are and most of them (including me, but not all) are just copy pasting those words (especially when it comes to chinese or japanese characters) from excel to the Localizable.strings via Xcode.

Features

  • Multi-App support. reusable keys for different applications.
  • Android and IOS support.
  • Integrated with Fastlane actions. (Fastlane actions localizr)
  • Default fallback for missing localizations.
  • Export and import to different file format.
  • Easy deployment: Deploy
  • Dockerized: docker pull michaelhenry119/localizr
  • Static files hosted in AWS S3 (Optional)
  • Snapshots

DEMO

username: demo
password: localizr

IOS Client

I have created a demo IOS App, You can pull it from Localizr.swift.

For Developers

Strings Generator

http://{your_server.com}/app/{app_slug}.{locale_code}

Format

iOS

Android

Integrate to your Android or IOS Project?

By using Fastlane. Currently localizr action is not officially available in fastlane repo, so you have to manually grab it from here fastlane/actions and paste the actions folder directly to your project 's fastlane folder in order to make this available to your local. here is the shortcut:

# from your workplace root folder:
$ curl -o fastlane/actions/localizr.rb https://raw.githubusercontent.com/michaelhenry/Localizr/master/fastlane/actions/localizr.rb
$ fastlane actions localizr

fastlane actions localizr

Sample configuration on IOS

desc "Submit build to TestFlight."
lane :beta do
  increment_build_number
  # ...
  localizr(
    localizr_server: 'http://your_localizr_server',
    localizr_api_token: 'your-auth-token-from-admin-page',
    locale_codes:  'en,ja,pt,zh,es',
    localizr_app_slug: 'your-app-slug',
    output_target_path: 'ExampleApp',
    platform: 'ios',
  )
  gym
  # ...
end

Sample configuration on Android

lane :beta do
  localizr(
    localizr_server: 'http://your_localizr_server',
    localizr_api_token: 'your-auth-token-from-admin-page',
    locale_codes:  'en,ja,pt,zh,es',
    localizr_app_slug: 'your-app-slug',
    output_target_path: 'res'
  ),
  gradle(
    task: 'assemble',
    build_type: 'Release'
  )
  # ...
end

You can also use environment variables if you dont want to configure it from Fastfile:

export FL_LOCALIZR_SERVER='http://your_localizr_server'
export FL_LOCALIZR_API_TOKEN='your-auth-token-from-admin-page'
export FL_LOCALIZR_APP_SLUG='your-app-slug'
export FL_LOCALIZR_BASE_LOCALE_CODE='en'
export FL_LOCALIZR_LOCALE_CODES='en,es,ja,zh,pt'
export FL_LOCALIZR_PLATFORM='ios'
export FL_LOCALIZR_OUTPUT_TARGET_PATH='ExampleApp'

Example:

desc "Submit build to TestFlight."
lane :beta do
  increment_build_number
  # ...
  localizr
  gym
  # ...
end

S3 Configuration

This is optional, but you can enable this by providing valid information for the following in the environment variables.

export AWS_ACCESS_KEY_ID='Your aws access key id'
export AWS_SECRET_ACCESS_KEY='Your secret key'
export AWS_STORAGE_BUCKET_NAME='Name of the bucket'

For Non-Developers, Translators or even Developers.

How to use Localizr?

  1. Create different Locales set the name and the code.
  2. Create an App and set the base_locale if you want to have a fallback for missing localized strings.
  3. Create Different Keys.
  4. Match the Keys with the App so you can re-use the keys to other apps too.
  5. Finally, populate the localized strings .

Does it look difficult?

Then try to use the importer (csv, xls, xlsx, tsv, json, yaml).

You can find the sample csv files in the sample_data folder.

  1. Import the Locales.csv to Locales section.
  2. Import the Apps.csv to Apps section.
  3. Import the App's Keys.csv to App 's Keys section.
  4. Import the Localized String.csv to Localized String section.

import admin import

import button

import change diff

How about exporting?

Just find the EXPORT button, select the format and that's it.

Deployment

Using Heroku

Just click this button >++> Deploy

If you're using heroku's free dyno and the waking time is longer than expected, you disable the auto migration option by setting the environment variable:

LOCALIZR_DISABLE_AUTO_MIGRATION=1

Using Docker

sample config of docker-compose.yml

version: '3'

services:
  db:
    image: postgres:9.4
    volumes:
      - pg-data:/var/lib/postgresql/data
    ports:
      - "5432:5432"  
    environment:
      - POSTGRES_PASSWORD=your_db_password

  localizr:
    image: michaelhenry119/localizr:latest
    container_name: localizr
    ports:
      - "80:8001"
    environment:
      # Reference: postgres://USER:PASSWORD@HOST:PORT/NAME, this example is using the default postgres database.
      - DATABASE_URL=postgres://postgres:your_db_password@db:5432/postgres
      # You have to define your host name here to prevent any random attacks.
      - ALLOWED_HOSTS=0.0.0.0,localizr.domain.com,or_any_domain
      # This is optional, you can assign a default then change it later from the admin page. 
      # Or you can do it programatically after you mount the image.
      - ADMIN_USERNAME=admin
      - ADMIN_PASSWORD=change_me_later
      - [email protected]
    depends_on:
      - db
volumes:
  pg-data:

Local setup (via virtualenv)

Install virtualenv

$ pip install virtualenv

Create a virtual environment venv

$ virtualenv venv

Activate the virtual environment

$ source venv/bin/activate

Install the dependencies

$ pip install -r requirements_local.txt

Migrate to create a local sqlite database

$ python manage.py migrate --settings=project.settings

Create a super user (login account)

$ python manage.py createsuperuser --settings=project.settings

Run the local server

$ python manage.py runserver --settings=project.settings

open http://127.0.0.1:8000/ from your browser and use the login credentials you provided.

Snapshot

Snapshot is supported by passing a query param ?snapshot=your_any_key_or_build_number to the localizedkeystrings request.

Recommendation and Automation:

With using CI and Fastlane, create a script or use fastlane actions localizr to download and update all the localization strings before gym method, So we can always make sure that all strings are updated.

TODO:

  • iOS format support
  • Android format support
  • Import/Export contents via CSV file
  • CI
  • Test cases
  • Docker container support.
  • Snapshot support.
  • Interactive UI.
  • Able to use google translate for some missing translations.

Author

Michael Henry Pantaleon, [email protected]

License

Localizr is available under the MIT license. See the LICENSE file for more info.

localizr's People

Contributors

dependabot[bot] avatar michaelhenry avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

localizr's Issues

Cannot pull latest release image

Trying to pull the latest release docker image 1.2.14 results in an error. Seems the image is not available in the docker repo.

Pulling localizr (michaelhenry119/localizr:v1.2.14)...
ERROR: Get https://registry-1.docker.io/v2/michaelhenry119/localizr/manifests/v1.2.14: unauthorized: incorrect username or password

Allow key/values groupings using dot.

Example:

pirate.time.formats.short = arrrround %H'ish

Will be

Yml format:

pirate:
  time:
    formats:
      short: "arrrround %H'ish"

In json format

{"pirate.time.formats.short":"arrrround %H'ish"}

And so on...

Allow concurrent updates without overwriting values not edited

When editing a String that has language A and B:

  1. User A Open String(A,B) to edit language A
  2. User B Open String(A,B) to edit language B
  3. User A edits language A and stores String(A,B)
  4. User B edits language B and stores String(A,B)

Result:

In Step 4 User B overwrites language A with the state how it was at step 2 when he first opened it.

This means, edits made by User A at step 3 get overwritten and lost.

Expected

Both edits are stored separately and without overwriting other language data.

Storing a modified string should only write the languages edited by the user, not the rest he didn't touch.

Localization crowdsourcing

  • Able to have shared database for common translations within the internet.
  • Able to accept/reject the translations submitted by any anyone who wants to contribute.

Ability to disable automigration

This is usuful especially if only uses heroku โ€˜s free dyno which sleeps most of the time, this will reduce the time of waking up the localizr server.

Env:

LOCALIZR_DISABLE_AUTO_MIGRATION=1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.