# XCodeLocalize
## Requirments
Python3.9+
## Installation
### Using pip:
```
pip3 install xcodelocalize
```
Аlso available installations via poetry or .whl file from github releases
## Usage
### Prepare your xcode project
1. Create Localizable.strings file and fill it with strings you want to localize.
```
/* optional description */
"[key]" = "[string]";
/* Example: */
"welcome text" = "Welcome to XCodelocalize";
```
2. Go to the project settings, add the desired languages.
3. Create localization (.strings) files for all selected languages.
[There is a nice tutorial about ios app localization by kodeco (the new raywenderlich.com)](https://www.kodeco.com/250-internationalizing-your-ios-app-getting-started)
### Localize
`cd` to project root folder and run
```
xcodelocalize [OPTIONS]
```
or
```
python3 -m xcodelocalize [OPTIONS]
```
#### Options
* `--base-language`: code of the language from which all strings will be translated. _[default: 'en']_
* `--override / --no-override`: a boolean value that indicates whether strings that already exist in the file will be translated. Retranslate if `override`, skip if `no-override`. _[default: no-override]_
* `--file`: Names of the strings files to be translated. Multiple files can be specified. If not specified, all files will be translated. _[default: None]_
Example:
```
xcodelocalize --file InfoPlist
xcodelocalize --file InfoPlist --file MainStoryboard --file Localizable
```
* `--key`: Keys of the strings to be translated. Multiple keys can be specified. If not specified, all keys will be translated. _[default: None]_
* `--language`: Language codes of the strings files to be translated. Multiple language codes can be specified. If not specified, all files will be translated. _[default: None]_
* `--log-level`: One from [progress|errors|group|string]. _[default: group]_
* `--help`: Show info
## Features:
* The tool looks for .strings files in the current directory recursively, grouping and translating fully automatically. You can even run it in the root directory and localize all your projects at once.
* Regular .strings, Info.plist, storyboards and intentdefinition files are supported.
* Formated strings with %@ are supported.
* Multiline strings are supported.
* Key and value must **not contain double quotes `"`**. Other quotes are supported.
* Comments are supported and will be copied to all files. Comments must **not contain substrings in localizable strings format with comment, such as `/*[comment]*/ "[key]" = "[value]";`**.
## Automation
You can go to `Target -> Build Phases -> New Run Script Phase` in your xcode project and paste `xcodelocalize` there. It will localize necessary strings during build and your localization files will always be up to date.
---
## Bonus
Nice swift extension that allows you to do this
```swift
"welcome text".localized // will return "Welcome to XCodelocalize"
```
```swift
extension String {
var localized: String {
NSLocalizedString(self, tableName: nil, bundle: .main, value: self, comment: "")
}
func localized(_ arguments: String...) -> String {
String(format: self.localized, locale: Locale.current, arguments: arguments)
}
}
```
Raw data
{
"_id": null,
"home_page": "https://pypi.org/project/xcodelocalize/",
"name": "xcodelocalize",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9,<4.0",
"maintainer_email": "",
"keywords": "xcode,localize,strings,localization,ios",
"author": "MarkParker5",
"author_email": "markparker.it@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/df/79/dfa36a238a98697fbebc9463d9faaeeec6e0addbe69f233d771c0b2814a2/xcodelocalize-1.0.1.tar.gz",
"platform": null,
"description": "# XCodeLocalize\n\n## Requirments \n\nPython3.9+\n\n## Installation\n\n### Using pip:\n\n```\npip3 install xcodelocalize \n```\n\n\u0410lso available installations via poetry or .whl file from github releases\n\n## Usage\n\n### Prepare your xcode project\n\n1. Create Localizable.strings file and fill it with strings you want to localize.\n ```\n /* optional description */\n \"[key]\" = \"[string]\";\n\n /* Example: */\n \"welcome text\" = \"Welcome to XCodelocalize\";\n ``` \n\n2. Go to the project settings, add the desired languages. \n\n3. Create localization (.strings) files for all selected languages. \n\n[There is a nice tutorial about ios app localization by kodeco (the new raywenderlich.com)](https://www.kodeco.com/250-internationalizing-your-ios-app-getting-started)\n\n### Localize\n\n`cd` to project root folder and run\n\n```\nxcodelocalize [OPTIONS]\n```\n\nor\n\n```\npython3 -m xcodelocalize [OPTIONS]\n```\n\n#### Options\n\n* `--base-language`: code of the language from which all strings will be translated. _[default: 'en']_\n\n* `--override / --no-override`: a boolean value that indicates whether strings that already exist in the file will be translated. Retranslate if `override`, skip if `no-override`. _[default: no-override]_\n\n* `--file`: Names of the strings files to be translated. Multiple files can be specified. If not specified, all files will be translated. _[default: None]_ \n \n Example:\n ```\n xcodelocalize --file InfoPlist\n xcodelocalize --file InfoPlist --file MainStoryboard --file Localizable \n ```\n\n* `--key`: Keys of the strings to be translated. Multiple keys can be specified. If not specified, all keys will be translated. _[default: None]_\n\n* `--language`: Language codes of the strings files to be translated. Multiple language codes can be specified. If not specified, all files will be translated. _[default: None]_\n\n* `--log-level`: One from [progress|errors|group|string]. _[default: group]_\n\n* `--help`: Show info\n\n## Features:\n\n* The tool looks for .strings files in the current directory recursively, grouping and translating fully automatically. You can even run it in the root directory and localize all your projects at once.\n\n* Regular .strings, Info.plist, storyboards and intentdefinition files are supported.\n\n* Formated strings with %@ are supported.\n\n* Multiline strings are supported.\n\n* Key and value must **not contain double quotes `\"`**. Other quotes are supported.\n\n* Comments are supported and will be copied to all files. Comments must **not contain substrings in localizable strings format with comment, such as `/*[comment]*/ \"[key]\" = \"[value]\";`**.\n\n## Automation\n\nYou can go to `Target -> Build Phases -> New Run Script Phase` in your xcode project and paste `xcodelocalize` there. It will localize necessary strings during build and your localization files will always be up to date.\n\n---\n\n## Bonus\n\nNice swift extension that allows you to do this\n```swift\n\"welcome text\".localized // will return \"Welcome to XCodelocalize\"\n```\n\n```swift\nextension String {\n var localized: String {\n NSLocalizedString(self, tableName: nil, bundle: .main, value: self, comment: \"\")\n }\n \n func localized(_ arguments: String...) -> String {\n String(format: self.localized, locale: Locale.current, arguments: arguments)\n }\n}\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tool for automatic search and localization of .strings files",
"version": "1.0.1",
"split_keywords": [
"xcode",
"localize",
"strings",
"localization",
"ios"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a15e7508e9f6ce48a0b25b0782f83a8d56207a48e7cde7cbcf9a93ce85f8e4f7",
"md5": "37c692d0e6643fe7379cd03445469b8d",
"sha256": "8ca3799a899fa1bee9cb74edc23b62eb19465977276375fdb397d9a53863ceb2"
},
"downloads": -1,
"filename": "xcodelocalize-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "37c692d0e6643fe7379cd03445469b8d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9,<4.0",
"size": 7562,
"upload_time": "2023-02-04T04:50:25",
"upload_time_iso_8601": "2023-02-04T04:50:25.554644Z",
"url": "https://files.pythonhosted.org/packages/a1/5e/7508e9f6ce48a0b25b0782f83a8d56207a48e7cde7cbcf9a93ce85f8e4f7/xcodelocalize-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "df79dfa36a238a98697fbebc9463d9faaeeec6e0addbe69f233d771c0b2814a2",
"md5": "02b95645a00ffe3d47d65a52b60d38ea",
"sha256": "d27a04b30e107b2240c2bfe932d884498555d710b95aed813e187ec4307e8d52"
},
"downloads": -1,
"filename": "xcodelocalize-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "02b95645a00ffe3d47d65a52b60d38ea",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9,<4.0",
"size": 6521,
"upload_time": "2023-02-04T04:50:27",
"upload_time_iso_8601": "2023-02-04T04:50:27.483151Z",
"url": "https://files.pythonhosted.org/packages/df/79/dfa36a238a98697fbebc9463d9faaeeec6e0addbe69f233d771c0b2814a2/xcodelocalize-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-02-04 04:50:27",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "xcodelocalize"
}