{"id":19777464,"url":"https://github.com/ilib-js/ilib-loctool-yaml","last_synced_at":"2025-09-17T23:31:38.282Z","repository":{"id":34642900,"uuid":"172765212","full_name":"iLib-js/ilib-loctool-yaml","owner":"iLib-js","description":"Ilib loctool plugin to parse and localize YAML files","archived":false,"fork":false,"pushed_at":"2024-11-08T16:45:06.000Z","size":69,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-11-12T05:30:41.106Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iLib-js.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-26T18:18:56.000Z","updated_at":"2022-02-08T02:13:30.000Z","dependencies_parsed_at":"2024-11-12T05:35:38.738Z","dependency_job_id":null,"html_url":"https://github.com/iLib-js/ilib-loctool-yaml","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-yaml","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-yaml/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-yaml/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-yaml/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iLib-js","download_url":"https://codeload.github.com/iLib-js/ilib-loctool-yaml/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233430256,"owners_count":18675058,"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","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-11-12T05:25:05.142Z","updated_at":"2025-09-17T23:31:32.959Z","avatar_url":"https://github.com/iLib-js.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003e :warning: **Deprecation Notice** :warning:\n\u003e This repository has been deprecated. Please use the corresponding package from the [iLib-js monorepo](https://github.com/iLib-js/ilib-mono) instead.\n\n# ilib-loctool-yaml\n\nIlib loctool plugin to parse and localize YAML files.\n\n## Configuration\n\nBy default, plugin will localize source `.yml` and `.yaml` files,\ne.g. `/project/en.yml`,  and write localized file\nto a subfolder: `/project/resources/ru-RU/en.yml`.\n\nThe plugin will look for the `yaml` property within the `settings`\nof your `project.json` file. The following settings are\nused within the yaml property:\n\n- `mappings`: a mapping between file matchers and an object that gives\n  info used to localize the files that match it. This allows different\n  yaml files within the project to be processed with different schema.\n  The matchers are\n  a [micromatch-style string](https://www.npmjs.com/package/micromatch),\n  similar to the the `includes` and `excludes` section of a\n  `project.json` file. The value of that mapping is an object that\n  can contain the following properties:\n  - `template`: a path template to use to generate the path to\n    the translated output files. The template replaces strings\n    in square brackets with special values, and keeps any characters\n    intact that are not in square brackets. The default template,\n    if not specified is \"resources/[localeDir]/[filename]\".\n    The plugin recognizes and replaces the following strings\n    in template strings:\n    - [dir] the original directory where the matched source file\n      came from. This is given as a directory that is relative\n      to the root of the project. eg. \"foo/bar/strings.yaml\" -\u003e \"foo/bar\"\n    - [filename] the file name of the matching file.\n      eg. \"foo/bar/strings.yaml\" -\u003e \"strings.yaml\"\n    - [basename] the basename of the matching file without any extension\n      eg. \"foo/bar/strings.yaml\" -\u003e \"strings\"\n    - [extension] the extension part of the file name of the source file.\n      etc. \"foo/bar/strings.yaml\" -\u003e \"yaml\"\n    - [locale] the full BCP-47 locale specification for the target locale\n      eg. \"zh-Hans-CN\" -\u003e \"zh-Hans-CN\"\n    - [language] the language portion of the full locale\n      eg. \"zh-Hans-CN\" -\u003e \"zh\"\n    - [script] the script portion of the full locale\n      eg. \"zh-Hans-CN\" -\u003e \"Hans\"\n    - [region] the region portion of the full locale\n      eg. \"zh-Hans-CN\" -\u003e \"CN\"\n    - [localeDir] the full locale where each portion of the locale\n      is a directory in this order: [langage], [script], [region].\n      eg, \"zh-Hans-CN\" -\u003e \"zh/Hans/CN\", but \"en\" -\u003e \"en\".\n    - [localeUnder] the full BCP-47 locale specification, but using\n      underscores to separate the locale parts instead of dashes.\n      eg. \"zh-Hans-CN\" -\u003e \"zh_Hans_CN\"\n  - `excludedKeys` - an array of keys that must be excluded from a\n    ResultSet. Excluded key will also affect all its children\n    and ignore them too. It only allows the direct key exclusion,\n    i.e. a sequence of keys can not be used.\n  - `commentPrefix` - a string that defines prefix for context comment for\n    translators. Only comments that start with the provided string will\n    be extracted and added to ResultSet, all other are ignored.\n- `checkTranslatability`: by default, the plugin tries to guess which values\n  in the file are strings for translation and filter out others;\n  setting `checkTranslatablility`: false will disable this behaviour and all\n  values from the file will be extracted.\n\nExample configuration:\n```json\n{\n  \"settings\": {\n    \"yaml\": {\n      \"mappings\": {\n        \"**/source.yml\": {\n          \"template\": \"resources/[localeDir]/source.yaml\"\n        },\n        \"src/**/strings.yaml\": {\n          \"template\": \"[dir]/strings.[locale].yaml\",\n          \"excludedKeys\": [\n            \"one\",\n            \"another\",\n            \"test\"\n          ],\n          \"commentPrefix\": \"L10N:\"\n        }\n      }\n    }\n  }\n}\n```\n\nIn the above example, any file named `souce.yml` will be parsed.\nThe output files are saved to the `resources` directory.\n\nAlso files named `strings.yaml` that are located in directory `src`\nor any of its subdirectories will be parsed using specified `excludedKeys`\nand `commentPrefix` rules.\n\n## Providing context comments\n\nThe plugin automatically parses yaml comments and assigns them\nto corresponding strings as context comments.\n\nA context comment must be placed above the source string.\nIt's also possible to use multiline comments.\n\n**Same line comments are ignored!**\n\n```yaml\nheader_text: \"Header\" #ignored comment\n# Comment for article_title.\narticle_title: \"Article:\"\n# Comment for article_summary,\n# it includes view count and edit count values.\narticle_summary: \"Stats: {view_count} views, {edit_count} edits\"\n```\n\nComments are trimmed upon extraction, therefore there's no\ndifference between these two comments.\n```yaml\n#comment\nfirst: \"first\"\n#     comment \u003csome extra space chars here\u003e\nsecond: \"second\"\n```\n\nMultiline comments will preserve line breaks as well as spaces\non a new line (only space chars at the beginning of the\nfirst line and at the end of the last is trimmed):\n\n```yaml\n#    Multiline comment\n#    with some extra spaces in between \u003csome extra space chars here\u003e\n```\nwould be parsed as\n`Multiline comment\\n    with some extra spaces in between`\n\n## Legacy setup\n**Important: automatic schema files lookup is disabled once `mappings`\nsection is specified in the `project.json`! Use configration parameters\nin a mapping as described above.**\n\nPrior mappings introduction that happened in v1.3.0 the plugin behavior\nwas configurable via `*-schema.json` files.\n\nFor each source file plugin will search for a schema file named\n`\u003csourceFileName\u003e-schema.json` in the same dirctory the source\nfile is located.\n\n### Schema file\n\nExample of `*-schema.json` file:\n```json\n{\n  \"useLocalizedDirectories\": false,\n  \n  \"excluded_keys\": [\n    \"testKey\",\n    \"anotherExcludedKey\"\n  ],\n  \n  \"outputFilenameMapping\": {\n    \"ru-RU\": \"/project/translations/ru.yml\"\n  }\n}\n```\n\n`useLocalizedDirectories` - specifies whether localized file should\nbe placed in a separate directory. Default: `true`\n\n`excluded_keys` - array of keys to be excluded from localization\n(in `v1.3.0` this key was changed to `excludedKeys`, nevertheless the\noriginal key with an underscore is still supported even in mappings)\n\n`outputFilenameMapping` - array of mappings that\nspecify output path for a locale: `\u003clocaleName\u003e: \u003cpath`\n\n## License\n\nThis plugin is license under Apache2. See the [LICENSE](./LICENSE)\nfile for more details.\n\n## Release Notes\n\n### v1.5.1\n\n- update dependencies\n- make it work on node 10 \u0026 12\n- convert unit tests from nodeunit to jest\n\n### v1.5.0\n\n- added checkTranslatability setting to turn on or off the ability\n  to guess whether values are translatable. Default is true, same\n  as before, but now you can turn that off and allow all\n  values to be translated.\n\n### v1.4.1\n\n- update dependencies\n\n### v1.4.0\n\n- Add a hash of the file name into the key for each resource so that\nresource \"a\" from file1 does not conflict with resource \"a\" in file2.\n- Minimum version of node that this can run on is now v10\n\n### v1.3.0\n- Add support for mappings in yaml config that allows custom output\nfile naming and use of schema per-mapping\n- Add `commentPrefix` key to the schema that allows to specify prefix\nfor context comments that are extracted along with source strings\n\n### v1.2.0\n- Add support of yaml comments that enables providing context\ncomments for translators\n\n### v1.1.1\n\n- Fix a bug where the pseudo locales were not initialized properly.\n  This fix gets the right set of locales from the project settings to\n  see if any of them are pseudo locales.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-loctool-yaml","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filib-js%2Filib-loctool-yaml","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-loctool-yaml/lists"}