{"id":13411543,"url":"https://github.com/daxslab/spia","last_synced_at":"2025-10-09T14:17:58.635Z","repository":{"id":8885516,"uuid":"10603548","full_name":"daxslab/spia","owner":"daxslab","description":"simple python internationalization api","archived":false,"fork":false,"pushed_at":"2019-06-03T01:02:00.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-07-31T20:47:59.072Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daxslab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-06-10T15:39:37.000Z","updated_at":"2019-06-03T01:02:02.000Z","dependencies_parsed_at":"2022-08-28T04:55:14.013Z","dependency_job_id":null,"html_url":"https://github.com/daxslab/spia","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daxslab/spia","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxslab%2Fspia","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxslab%2Fspia/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxslab%2Fspia/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxslab%2Fspia/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daxslab","download_url":"https://codeload.github.com/daxslab/spia/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daxslab%2Fspia/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001527,"owners_count":26083117,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:14.390Z","updated_at":"2025-10-09T14:17:58.619Z","avatar_url":"https://github.com/daxslab.png","language":"Python","funding_links":[],"categories":["Web Development"],"sub_categories":["Python"],"readme":"**SPIA, simple python internationalization api**\n================\n\nQuickly and easy, internationalize your python applications\n\n**About**\n\nSPIA makes easy the internationalization process in a on-growing python application, with a pure python (and pythonic) internationalization.\n**SPIA is not a complete i18n API yet, but maybe in the future... well, it maybe is not an api yet...**\n\n**SPIA is now python 3.x compatible**\n\nHow it works\n================\n\n**Internationalization files**\n\nThe SPIA internationalization files are python modules that contains a dictionary with the key-text peers, the module names correspond to a simplified locale name, for example: \"en-us.py\" for United States english or \"es-es.py\" for Spain spanish, this is an example of a es-es.py content:\n\n```python\n# coding: utf8\n\nkeys = {\n'home' : 'casa',\n'keyboard' : 'teclado',\n'computer' : 'computadora',\n'my name is %s' : 'mi nombre es %s'\n}\n```\nSPIA can find the correct module for the system locale and replace the code keywords for the correct translated strings.\n\n**Python code**\n\nThis is an example of a python application using SPIA:\n\n```python\nimport spia.internationalizator as internationalizator # import the SPIA internationalizator\nfrom spia.internationalizator import _ # import the internationalization function, IN THIS CASE: _()\n\"\"\"\nFor another function caller (for example T):\nfrom spia.internationalizator import _ as T\n\"\"\"\n\ninternationalizator.load_locale_chains(\"/app/locale_dir\") # the locale dir contains the internationalization files\n\nprint _('home')\nprint _('keyboard')\nprint _('computer')\nprint _('my name is %s', 'Pepe')\n```\nOutput in a spanish eviroment:\n```\ncasa\nteclado\ncomputadora\nmi nombre es Pepe\n```\nOutput in a english eviroment:\n```\nhome\nkeyboard\ncomputer\nmy name is Pepe\n```\n\nTo force a defined locale you could use:\n```python\ninternationalizator.force('es-es') # force translation to Spain spanish\ninternationalizator.force('es_ES') # same\ninternationalizator.force('es') # force translation to spanish\ninternationalizator.force(None) # back to use enviroment locale\n# or\ninternationalizator.force('') # back to use enviroment locale\n```\n\n**Creator**\n\nSPIA has a creator module (or script), that create or update the locale files (internationalization files) for you, it obtain the internationalization strings (by default the _('string') function) from a python file, and create (or update) the locale module specified with the -l option. we can use it in that way:\n\n    python creator.py my_python_file.py /my_locales_folder/ -l es-es\n\nA different function call can be specified with the -f option, for example, for use the T('string') function call:\n\n    python creator.py my_python_file.py /my_locales_folder/ -l es-es -f T\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaxslab%2Fspia","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaxslab%2Fspia","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaxslab%2Fspia/lists"}