{"id":15728280,"url":"https://github.com/kt3k/t10","last_synced_at":"2025-03-13T02:31:15.751Z","repository":{"id":19129958,"uuid":"22359554","full_name":"kt3k/t10","owner":"kt3k","description":":globe_with_meridians: Translation (t10) for browser","archived":false,"fork":false,"pushed_at":"2020-05-31T01:01:28.000Z","size":279,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-01T22:59:21.829Z","etag":null,"topics":["browser","i18n","javascript","language","translate"],"latest_commit_sha":null,"homepage":"https://npm.im/t10","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kt3k.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":"2014-07-28T22:06:32.000Z","updated_at":"2020-05-09T05:17:20.000Z","dependencies_parsed_at":"2022-09-15T01:11:17.411Z","dependency_job_id":null,"html_url":"https://github.com/kt3k/t10","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Ft10","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Ft10/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Ft10/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kt3k%2Ft10/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kt3k","download_url":"https://codeload.github.com/kt3k/t10/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243327821,"owners_count":20273753,"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":["browser","i18n","javascript","language","translate"],"created_at":"2024-10-03T23:01:52.404Z","updated_at":"2025-03-13T02:31:15.422Z","avatar_url":"https://github.com/kt3k.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# t10 v1.0.2\n\n\u003e Translation for browser, 642B minified+gzipped\n\n[![CircleCI](https://circleci.com/gh/kt3k/t10.svg?style=svg)](https://circleci.com/gh/kt3k/t10)\n[![codecov](https://codecov.io/gh/kt3k/t10/branch/master/graph/badge.svg)](https://codecov.io/gh/kt3k/t10)\n[![Greenkeeper badge](https://badges.greenkeeper.io/kt3k/t10.svg)](https://greenkeeper.io/)\n\n## Usage\n\nFirst, load the [script](https://unpkg.com/t10/dist/t10.js):\n```html\n\u003cscript type=\"text/javascript\" src=\"path/to/t10.js\"\u003e\u003c/script\u003e\n```\n\nSecond, set the translation resource:\n\n```javascript\nt10.setResource({\n  id_foo: 'Translated foo!',\n  id_bar: 'Translated bar!',\n  id_baz: 'Translated baz!'\n});\n```\n\nFinally, perform the translation:\n\n```javascript\nt10.scan();\n```\n\nThat's it. This performs the translation on the entire page synchronously.\n\nWith the above call the following html:\n\n```html\n\u003cp\u003e\n  \u003ct\u003eid_foo\u003c/t\u003e\n  \u003cspan class=\"t-text-done\"\u003eid_bar\u003c/span\u003e\n  \u003cinput class=\"t-attr-done\" placeholder=\"t:id_baz\" /\u003e\n\u003c/p\u003e\n```\n\nChanges in to:\n\n```html\n\u003cp\u003e\n  Translated foo!\n  \u003cspan class=\"t-text\"\u003eTranslated bar!\u003c/span\u003e\n  \u003cinput class=\"t-attr\" placeholder=\"Translated baz!\" /\u003e\n\u003c/p\u003e\n```\n\n---\n\nAlternatively you can use via npm.\n\nFirst install t10 locally:\n\n    npm i t10\n\nThen require / import it and use it:\n\n```js\nconst t10 = require('t10');\n```\n\nor:\n\n```js\nimport * as t10 from require('t10');\n```\n\nThe rest is the same.\n\n\n## What *t10.scan()* translates\n\n### *t* tag\n\n```html\n...\u003ct\u003estr_id\u003c/t\u003e...\n```\ntranslated into:\n\n```html\n...translated str_id...\n```\n\n\n### *.t-text* class\n\n```html\n\u003cspan class=\"t-text\"\u003estr_id\u003c/span\u003e\n```\n\ntranslated into:\n\n```html\n\u003cspan class=\"t-text-done\"\u003etranslated str_id\u003c/span\u003e\n```\n\n\n### *.t-attr* class\n\n```html\n\u003cinput type=\"text\" class=\"t-attr\" placeholder=\"t:str_id\" /\u003e\n```\n\ntranslated into:\n\n```html\n\u003cinput type=\"text\" class=\"t-attr-done\" placeholder=\"translated str_id\" /\u003e\n```\n\n# Hide untranslated elements\n\nYou can hide untranslated elements by the following style:\n\n```css\nt, .t-text, .t-attr {\n    visibility: hidden;\n}\n```\n\n**Note**: `t` tag and `.t-text`, `.t-attr` classes are going to be removed after the translation.\n\n# Select the best fit language from available list\n\n### Basic Usage\n\n```javascript\nt10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('ja'); // =\u003e 'ja'\nt10.setAvailables(['en', 'fr', 'ja']).getBestLanuuage('de'); // =\u003e 'en' # the first available is the default\nt10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('en.US'); // =\u003e 'en'\nt10.setAvailables(['en', 'fr', 'ja']).getBestLanguage('ja.JP'); // =\u003e 'ja'\n```\n\n### Typical Usage\n\n```javascript\nvar language = t10.setAvailables(['en', 'fr', 'ja']).getBestLanguage(getFromSystem());\n\n$.getScript('path/to/resource/' + language + '.js').then(function () {\n    t10.scan();\n});\n```\n\n# Translate\n\n`t` function translates a single key.\n\n```\nt10.setResource({pen: 'ペン'});\n\nt10.t('pen'); // =\u003e ペン\n```\n\n# Dependency\n\n- None\n\n# License\n\nMIT License (Yoshiya Hinosawa)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkt3k%2Ft10","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkt3k%2Ft10","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkt3k%2Ft10/lists"}