{ "info": { "author": "Nicolas Cornette", "author_email": "nicolas.cornette@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Topic :: Software Development :: Build Tools" ], "description": "Mobile Text Tools\r\n=================\r\n\r\n.. image:: https://travis-ci.org/ncornette/python-mobile-text-tool.svg?branch=master\r\n :target: https://travis-ci.org/ncornette/python-mobile-text-tool\r\n\r\n.. image:: https://codecov.io/gh/ncornette/python-mobile-text-tool/branch/master/graph/badge.svg\r\n :target: https://codecov.io/gh/ncornette/python-mobile-text-tool\r\n\r\n.. image:: https://api.codacy.com/project/badge/Grade/a37555ff09aa4a09a51d7b3a34e810c2\r\n :target: https://www.codacy.com/app/nicolas-cornette/python-mobile-text-tool?utm_source=github.com&utm_medium=referral&utm_content=ncornette/python-mobile-text-tool&utm_campaign=Badge_Grade\r\n\r\n.. image:: https://img.shields.io/pypi/v/Mobile-Text-Tool.svg?maxAge=2592000\r\n :target: https://pypi.python.org/pypi/Mobile-Text-Tool\r\n\r\nMobile Text Tools is a set of tools to export translations to ``Android``\r\nand ``IOS`` mobile applications. It provides a data model represented in\r\n``json`` and can read and write different formats.\r\n\r\nFeatures\r\n--------\r\n\r\n- import .csv, .xls, .xlsx, .json\r\n- export .csv, .json, android resources, ios resoures\r\n- custom rows format import and export\r\n- string escape\r\n- token replacement: you must use the ``{}`` or ``{1}..{n}`` notation\r\n in source files\r\n\r\nCLI\r\n---\r\n\r\n::\r\n\r\n $ update_wordings --help\r\n usage: update_wordings [-h] [-o [OUT_FILE [OUT_FILE ...]]]\r\n [-a ANDROID_RES_DIR] [-i IOS_RES_DIR]\r\n [--android-resname ANDROID_RESNAME]\r\n [--ios-resname IOS_RESNAME] [-s] [-f FORMAT_CONFIG]\r\n input_file\r\n \r\n Export wordings for Android & IOS.\r\n \r\n positional arguments:\r\n input_file .csv, .xls, .xlsx, .json formats are supported.\r\n \r\n optional arguments:\r\n -h, --help show this help message and exit\r\n -o [OUT_FILE [OUT_FILE ...]], --out-file [OUT_FILE [OUT_FILE ...]]\r\n .json or .csv output file path (default: [])\r\n -a ANDROID_RES_DIR, --android_res_dir ANDROID_RES_DIR\r\n resource directory for android strings (default: None)\r\n -i IOS_RES_DIR, --ios_res_dir IOS_RES_DIR\r\n resource directory for ios strings (default: None)\r\n --android-resname ANDROID_RESNAME\r\n filename for android resource (default: strings.xml)\r\n --ios-resname IOS_RESNAME\r\n filename for ios resource (default: i18n.strings)\r\n -s, --split-files Export sections as separate ios and android resource\r\n files, comment key is used for naming new files\r\n (default: False)\r\n -f FORMAT_CONFIG, --format-config FORMAT_CONFIG\r\n excel and csv format specifications config file\r\n (default: None)\r\n\r\n\r\nDefault csv and xls format specification configuration :\r\n\r\n.. code:: json\r\n\r\n {\r\n \"excel_sheet_reference\": 0,\r\n \"key_col\": 0,\r\n \"exportable_col\": 1,\r\n \"is_comment_col\": 2,\r\n \"comment_col\": 3,\r\n \"translations_start_col\": 4,\r\n \"exportable_value\": null,\r\n \"is_comment_value\": null,\r\n \"metadata_cols\": {}\r\n }\r\n\r\n- ``excel_sheet_reference``: is the worksheet number (int) or name (string) for excel import\r\n- ``exportable_value``: is the value to match in ``exportable_col`` to tell if the value will be exported to Android or IOS, can be a string or a list of strings, ``null`` will match ``True`` for any non empty value in the column.\r\n- ``is_comment_value``: same as ``exportable_value`` to tell if the line is a comment\r\n\r\nExample csv or xls table with default format :\r\n\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n| key | exportable | is_comment | comment | en | fr | de |\r\n+=================+==============+==============+==============+===========+===========+==============+\r\n| Menu | Yes | Yes | Menu Screen | | | |\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n| menu.welcome | Yes | | | Welcome | Bienvenue | Willkommen |\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n| menu.contact | Yes | | | Contact | Contact | Kontakt |\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n| Share | Yes | Yes | Share Screen | | | |\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n| share.share | Yes | | | Share | Partager | Teilen |\r\n+-----------------+--------------+--------------+--------------+-----------+-----------+--------------+\r\n\r\n\r\nTo generate translations for android and ios from ``.xlsx`` file :\r\n\r\n::\r\n\r\n $ update_wordings my_wordings.xlsx -i out/ios -a out/android\r\n\r\nTo generate translations from json file for android with custom resource\r\nfilename :\r\n\r\n::\r\n\r\n $ update_wordings my_wordings.json -a out/android --android-resname my_strings.xml\r\n\r\n\r\nPython interface\r\n----------------\r\n\r\n.. code:: python\r\n\r\n import mobileStrings\r\n\r\nRead :\r\n~~~~~~\r\n\r\nFunction ``read_file(f)`` from module ``text_in`` supports ``.xls``,\r\n``.xlsx``, ``.csv``, ``.json`` file formats.\r\n\r\n.. code:: python\r\n\r\n languages, wordings = mobileStrings.text_in.read_file('./test_translations.json')\r\n print ', '.join(languages)\r\n\r\n\r\n.. parsed-literal::\r\n\r\n en, fr, de, pt, it, es, nl, zh, ja, pl, pt_BR, ru, id, ko, ar, tr, th, sv\r\n\r\n\r\nRead custom formats :\r\n~~~~~~~~~~~~~~~~~~~~~\r\n\r\nFor formats represented as rows like ``.csv`` and ``.xls``, you can\r\nspecify columns numbers with ``FormatSpec``\r\n\r\n.. code:: python\r\n\r\n specs = mobileStrings.text_in.FormatSpec(0, 1, 2, 3, 4, bool, bool, {}) # Default format_spec (all params are optional)\r\n \r\n languages, wordings = mobileStrings.text_in.read_file('./test_translations.csv', specs)\r\n print ', '.join(languages)\r\n\r\n\r\n.. parsed-literal::\r\n\r\n en, fr, de, pt, it, es, nl, zh, ja, pl, pt_BR, ru, id, ko, ar, tr, th, sv\r\n\r\n\r\nQuery :\r\n~~~~~~~\r\n\r\nTo search a wording by its key, you can convert the ``list`` of\r\n``Wording`` to a ``dict``\r\n\r\n.. code:: python\r\n\r\n # wordings is a list, create a dict to query\r\n d = dict((w.key,w) for w in wordings)\r\n print('# keys: ')\r\n print '\\n'.join(d.keys())\r\n \r\n welcome_wording = d.get('menu.welcome')\r\n \r\n print('\\n# ' +welcome_wording.comment+':')\r\n print welcome_wording.translations.get('fr')\r\n print welcome_wording.translations.get('de')\r\n\r\n\r\n.. parsed-literal::\r\n\r\n # keys: \r\n menu.home\r\n menu.contact\r\n menu.share\r\n menu.welcome\r\n menu.news\r\n menu.share.not.exported\r\n menu.infos\r\n comment.generated\r\n comment.section\r\n \r\n # Title on menu header:\r\n Bienvenue !\r\n Willkommen!\r\n\r\n\r\nWrite :\r\n~~~~~~~\r\n\r\nWriting is very simple : use a ``write_`` function from the ``text_out``\r\nmodule. It supports ``Android``, ``IOS``, ``json``, ``csv`` output\r\nformats.\r\n\r\nFor mobile applications :\r\n\r\n.. code:: python\r\n\r\n mobileStrings.text_out.write_android_strings(languages, wordings, '~/dev/myAndProject/res')\r\n mobileStrings.text_out.write_ios_strings(languages, wordings, '~/dev/myIOSProject/res')\r\n\r\nCsv example :\r\n\r\n.. code:: python\r\n\r\n import cStringIO\r\n sf = cStringIO.StringIO()\r\n \r\n # Write csv in a file-like object, for the first 3 languages only\r\n mobileStrings.text_out.write_csv(languages[:3], wordings, sf)\r\n print sf.getvalue()\r\n sf.close()\r\n\r\n\r\n.. parsed-literal::\r\n\r\n key,exportable,is_comment,comment,en,fr,de\r\n comment.generated,Yes,Yes,Generated by mobile dev tools - Do not modify,,,\r\n menu.welcome,Yes,,Title on menu header,Welcome!,Bienvenue !,Willkommen!\r\n menu.home,Yes,,Home item,Home,Accueil,Start\r\n menu.news,Yes,,News item,News,Actualit\u00e9s,News\r\n comment.section,Yes,Yes,This is a section,,,\r\n menu.contact,Yes,,Contact item,Contact,Contact,Kontakt\r\n menu.infos,Yes,,Information pages item,Info,Infos,Informationen\r\n menu.share.not.exported,,,Share application item - not exported,Share,Partager,Teilen\r\n menu.share,Yes,,Share application item,Share,Partager,Teilen\r\n menu.share,Yes,,Share application item,,Partager,Teilen", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ncornette/python-mobile-text-tool", "keywords": "translations mobile development", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "Mobile-Text-Tool", "package_url": "https://pypi.org/project/Mobile-Text-Tool/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/Mobile-Text-Tool/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/ncornette/python-mobile-text-tool" }, "release_url": "https://pypi.org/project/Mobile-Text-Tool/1.1.2/", "requires_dist": null, "requires_python": null, "summary": "Tools for editing translations in mobile apps", "version": "1.1.2" }, "last_serial": 2136424, "releases": { "1.1.1": [ { "comment_text": "", "digests": { "md5": "312cf98892d96d3a43ff0c05e4d60504", "sha256": "aee5f04742dcc11e6fa7ff27fd50c9908b315cee9a491efa8bafafd69edafa37" }, "downloads": -1, "filename": "Mobile_Text_Tool-1.1.1-py2-none-any.whl", "has_sig": false, "md5_digest": "312cf98892d96d3a43ff0c05e4d60504", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 16719, "upload_time": "2016-05-25T11:46:14", "url": "https://files.pythonhosted.org/packages/ff/2f/d4d2c06dd045a039bb9d851b2021eabff288410ac634bcb59cab414d361a/Mobile_Text_Tool-1.1.1-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a07aa930ea9c5620bcae5707bbe79b1f", "sha256": "604cbaedefa100a4eafc0e25e9f63beeb8e76a75296aef368122dc98e441e02b" }, "downloads": -1, "filename": "Mobile-Text-Tool-1.1.1.tar.gz", "has_sig": false, "md5_digest": "a07aa930ea9c5620bcae5707bbe79b1f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13396, "upload_time": "2016-05-25T11:36:24", "url": "https://files.pythonhosted.org/packages/c9/33/092a85c7fcd50be677fc1c57d0963d09a5cca52e26897bda0569a0e607a5/Mobile-Text-Tool-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "c1417b6236f0ffc410469280b9d9cb3d", "sha256": "046ecac9a99ce5ab8090da5359c21bf8e6799d5e0bffa023abe2e487c842e973" }, "downloads": -1, "filename": "Mobile_Text_Tool-1.1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "c1417b6236f0ffc410469280b9d9cb3d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 16776, "upload_time": "2016-05-26T09:51:20", "url": "https://files.pythonhosted.org/packages/28/14/4eb67adc54fec603b312d18f5249661a9968e45f1ab14316d1f00cdb4663/Mobile_Text_Tool-1.1.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a1639e60a53350ee820cb53e5df109bd", "sha256": "c40e20cf4177832a05afbbb323703ebaf8eeb277411e862890281d121a6bf771" }, "downloads": -1, "filename": "Mobile-Text-Tool-1.1.2.tar.gz", "has_sig": false, "md5_digest": "a1639e60a53350ee820cb53e5df109bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13453, "upload_time": "2016-05-26T09:50:49", "url": "https://files.pythonhosted.org/packages/f7/16/379f843dd5f9c32d12020c6f8e9a2932b158c6eaa2d6c5dc33187c2e318a/Mobile-Text-Tool-1.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c1417b6236f0ffc410469280b9d9cb3d", "sha256": "046ecac9a99ce5ab8090da5359c21bf8e6799d5e0bffa023abe2e487c842e973" }, "downloads": -1, "filename": "Mobile_Text_Tool-1.1.2-py2-none-any.whl", "has_sig": false, "md5_digest": "c1417b6236f0ffc410469280b9d9cb3d", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 16776, "upload_time": "2016-05-26T09:51:20", "url": "https://files.pythonhosted.org/packages/28/14/4eb67adc54fec603b312d18f5249661a9968e45f1ab14316d1f00cdb4663/Mobile_Text_Tool-1.1.2-py2-none-any.whl" }, { "comment_text": "", "digests": { "md5": "a1639e60a53350ee820cb53e5df109bd", "sha256": "c40e20cf4177832a05afbbb323703ebaf8eeb277411e862890281d121a6bf771" }, "downloads": -1, "filename": "Mobile-Text-Tool-1.1.2.tar.gz", "has_sig": false, "md5_digest": "a1639e60a53350ee820cb53e5df109bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13453, "upload_time": "2016-05-26T09:50:49", "url": "https://files.pythonhosted.org/packages/f7/16/379f843dd5f9c32d12020c6f8e9a2932b158c6eaa2d6c5dc33187c2e318a/Mobile-Text-Tool-1.1.2.tar.gz" } ] }