GithubHelp home page GithubHelp logo

dulacp / igenstrings Goto Github PK

View Code? Open in Web Editor NEW
39.0 2.0 11.0 86 KB

Apple genstrings command on steroids by adding merging superpowers

License: MIT License

Python 61.66% Makefile 5.11% Objective-C 22.96% Shell 7.25% C++ 0.78% Objective-C++ 1.22% Swift 1.01%
i18n internationalization localization ios macos xcode

igenstrings's Introduction

igenstrings

build-status-image build-coverage-image pypi-version-image docs-image

Eventually, all things merge into one, and a river runs through it.

Enhance the genstrings command by adding merging capabilities
Documentation is available at https://igenstrings.readthedocs.org.

Features

  • Ensure your files are encoded in UTF-8 (as recommended by Apple now)
  • Takes care of runing the genstrings command on all files \*.m, \*.mm and \*.swift
  • Merge the results with previous version of the Localizable.string files you may have
  • Inform you if it works correctly

Installation

$ pip install igenstrings

Support

Python 2.7 Python 3.4+

Requirements

Ensure your *.strings files are UTF-8 encoded as Apple recommends it now :

It is recommended that you save strings files using the UTF-8 encoding, which is the default encoding for standard strings files. Xcode automatically transcodes strings files from UTF-8 to UTF-16 when they’re copied into the product.

Usage

$ igenstrings ./MyXcodeProjectDir

output

Running the script on path ./MyXcodeProjectDir
Excluded path regex: None
languages found : ['./MyXcodeProjectDir/en.lproj', './MyXcodeProjectDir/fr.lproj']
Job done for language: ./MyXcodeProjectDir/en.lproj
Job done for language: ./MyXcodeProjectDir/fr.lproj

Known Issues

  • The Apple genstrings command doesn't like path that contains spaces. So avoid subfolders containing spaces, otherwise the Localizable.string will not be complete
  • You need to respect the format used by the genstrings command unless it will breaks. So, to avoid issues use strictly the format below for each translated text. Also do not remove the line break between two fields or it will breaks too.
/* Comment for localizable string */
"Your string" = "Translated string";

/* Comment for localizable string */
"Your string #2" = "Translated string #2";

Credits

Tools used in rendering this package:

Contact

Pierre Dulac
@_dulacp

License

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

igenstrings's People

Contributors

asolovev avatar dulacp avatar mpozzoknx 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  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

igenstrings's Issues

Make it possible to save as UTF-8

Looks like Apple now recommends the use of UTF-8 for string files:

It is recommended that you save strings files using the UTF-8 encoding, which is the default encoding for standard strings files. Xcode automatically transcodes strings files from UTF-8 to UTF-16 when they’re copied into the product.

https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/Strings/Strings.html

Maybe just expose the encoding parameter in the outer save() method while keeping the current default?

def save(self, output_filename, encoding='utf16'):
   with io.open(output_filename, encoding=encoding, mode='w') as f:

Merge the results ?

Hi,
The program does not merge the results for me...
My old 'Localizable.strings' is modified with string already translated.

Exception: invalid file on valid UTF-8 strings file

INFO:root:Running the script on path
languages found ['/en.lproj']
iconv: /en.lproj/Localizable.strings: No such file or directory
DEBUG:root:"Czech" = "Tchèque";

DEBUG:root:2
ERROR:root:Line 2 of file '/en.lproj/Localizable.strings.old' raising the exception:
ERROR:root:Error: input files have invalid format.
Traceback (most recent call last):
File "/bin/pygenstrings-master/genstring.py", line 264, in
localize(opts.path, opts.excluded_paths)
File "
/bin/pygenstrings-master/genstring.py", line 216, in localize
merge(merged, old, new)
File "/bin/pygenstrings-master/genstring.py", line 180, in merge
old = LocalizedFile(old_fname, auto_read=True)
File "
/bin/pygenstrings-master/genstring.py", line 82, in init
self.read_from_file(fname)
File "~/bin/pygenstrings-master/genstring.py", line 128, in read_from_file
raise Exception('invalid file')
Exception: invalid file

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.