{"id":19777439,"url":"https://github.com/ilib-js/ilib-loctool-javascript","last_synced_at":"2025-04-30T19:32:22.736Z","repository":{"id":34642885,"uuid":"167045214","full_name":"iLib-js/ilib-loctool-javascript","owner":"iLib-js","description":"Javascript file handler plugin for loctool","archived":true,"fork":false,"pushed_at":"2024-11-12T17:46:52.000Z","size":195,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-05T02:24:38.654Z","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}},"created_at":"2019-01-22T18:26:25.000Z","updated_at":"2024-11-21T22:03:48.000Z","dependencies_parsed_at":"2023-09-24T10:04:59.094Z","dependency_job_id":null,"html_url":"https://github.com/iLib-js/ilib-loctool-javascript","commit_stats":{"total_commits":44,"total_committers":4,"mean_commits":11.0,"dds":"0.11363636363636365","last_synced_commit":"07b91f32b8322693a9fc384a78fb0b4465962b40"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-javascript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-javascript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-javascript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iLib-js%2Filib-loctool-javascript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iLib-js","download_url":"https://codeload.github.com/iLib-js/ilib-loctool-javascript/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251769474,"owners_count":21640909,"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:24:53.878Z","updated_at":"2025-04-30T19:32:22.729Z","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-javascript\n\nilib-loctool-javascript is a plugin for the loctool that\nallows it to read and localize javascript files.\n\n## Configuring the Plugin\n\n### Standard Settings\n\nTo use this plugin, you should set these two settings:\n\n- The `projectType` setting should be set to `custom`\n- The `resourceFileTypes` setting should be set to an object that\n  includes the `javascript` property. The value names the plugin\n  that will be used as a resource file format.\n\n### Custom Settings\n\nThe plugin will look for the `javascript` property within the `settings`\nof your `project.json` file. The following settings are\nused within the json property:\n\n- wrapper: specify a regular expression that matches the wrapper function\n  that contains strings to extract and unique ids\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  json 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    - schema: schema to use with that matcher. The schema is\n      specified using the `$id` of one of the schemas loaded in the\n      `schemas` property above. The default schema is \"strings-schema\"\n      which is given in the previous section.\n    - method: one of \"copy\" or \"sparse\"\n        - copy: make a copy of the source file and localize the\n          string contents. (This is the default method if not specified\n          explicitly.)\n        - sparse: make a copy of the source file but only\n          include localized strings\n    - template: a path template to use to generate the path to\n      the translated\n      output files. The template replaces strings in square brackets\n      with special values, and keeps any characters intact that are\n      not in square brackets. The default template, if not specified is\n      \"resources/[localeDir]/[filename]\". The plugin recognizes\n      and replaces the following strings 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.json\" -\u003e \"foo/bar\"\n        - [filename] the file name of the matching file.\n          eg. \"foo/bar/strings.json\" -\u003e \"strings.json\"\n        - [basename] the basename of the matching file without any extension\n          eg. \"foo/bar/strings.json\" -\u003e \"strings\"\n        - [extension] the extension part of the file name of the source file.\n          etc. \"foo/bar/strings.json\" -\u003e \"json\"\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\n\nExample configuration:\n\n```json\n{\n    \"settings\": {\n        \"json\": {\n            \"wrapper\": \"rb\\\\s*\\\\.getString(JS)?\",\n            \"schemas\": \"./json/schemas\",\n            \"mappings\": {\n                \"**/appinfo.json\": {\n                    \"schema\": \"http://www.lge.com/json/appinfo\",\n                    \"method\": \"sparse\",\n                    \"template\": \"resources/[localeDir]/appinfo.json\"\n                },\n                \"src/**/strings.json\": {\n                    \"schema\": \"http://www.lge.com/json/strings\",\n                    \"method\": \"copy\",\n                    \"template\": \"[dir]/strings.[locale].json\"\n                }\n            }\n        }\n    }\n}\n```\n\nIn the above example, any file named `appinfo.json` will be parsed with the\n`http://www.lge.com/json/appinfo` schema. Because the method is `sparse`,\nonly the parts of the json file that have translated strings in them will\nappear in the output. The output file name is sent to the `resources` directory.\n\nIn the second part of the example, any `strings.json` file that appears in\nthe `src` directory will be parsed with the schema `http://www.lge.com/json/strings`\nand a full copy of the file, including the parts that were not localized,\nwill be sent to the same directory as the source file. However, the\nlocalized file name will also contain the name of the locale to distinguish\nit from the source file.\n\nIf the name of the localized file that the template produces is the same as\nthe source file name, this plugin will throw an exception, the file will not\nbe localized, and the loctool will continue on to the next file.\n\n## Release Notes\n\n### v1.1.3\n\n- update dependencies\n- convert all unit tests from nodeunit to jest\n\n### v1.1.2\n\n- update dependencies\n\n### v1.1.1\n\n- deal with eslint's propensity of putting extra commas at the end of parameter lists\n  where they shouldn't be. This causes single-parameter strings not to be extracted.\n\n### v1.1.0\n\n- added the ability to use ilib-loctool-json as a resource file\n- added the ability to specify output file mappings and\n  output file name templates, similar to the other loctool plugins\n- updated dependencies\n- can now specify a regular expression to match the function wrapper of\n  strings\n- Use the logger provided by the loctool instead of using log4js directly (which doesn't\n  work well)\n- minimum version of node is now v10\n\n### v1.0.4\n\n- Updated dependencies to avoid security problems\n\n### v1.0.3\n\n- Fixed so that JavaScriptFileType.write passes the right name when asking for the resource\nfile type for javascript files.\n\n### v1.0.2\n\n- Fixed so that JavaScriptFileType passes the right props to\nthe JavaScriptFile constructor.\n\n## License\n\nCopyright © 2019, 2022 JEDLSoft\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-loctool-javascript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Filib-js%2Filib-loctool-javascript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Filib-js%2Filib-loctool-javascript/lists"}