{"id":17892745,"url":"https://github.com/neetjn/r-localize","last_synced_at":"2025-03-23T01:32:32.728Z","repository":{"id":57332461,"uuid":"119218870","full_name":"neetjn/r-localize","owner":"neetjn","description":"Localization plugin for Riot.js based off of Vue.js v-localize project.","archived":false,"fork":false,"pushed_at":"2018-06-29T02:01:17.000Z","size":571,"stargazers_count":5,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-09-26T12:48:53.167Z","etag":null,"topics":["google","i10n","i18n","javascript","locale","localize","node","riot","ts","typescript","webpack"],"latest_commit_sha":null,"homepage":"https://neetjn.github.io/r-localize/","language":"TypeScript","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/neetjn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-28T01:51:20.000Z","updated_at":"2018-12-04T20:20:11.000Z","dependencies_parsed_at":"2022-09-16T11:22:23.314Z","dependency_job_id":null,"html_url":"https://github.com/neetjn/r-localize","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neetjn%2Fr-localize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neetjn%2Fr-localize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neetjn%2Fr-localize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neetjn%2Fr-localize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neetjn","download_url":"https://codeload.github.com/neetjn/r-localize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221842117,"owners_count":16890112,"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":["google","i10n","i18n","javascript","locale","localize","node","riot","ts","typescript","webpack"],"created_at":"2024-10-28T14:44:13.676Z","updated_at":"2024-10-28T14:44:14.182Z","avatar_url":"https://github.com/neetjn.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# **r-localize**\n\n[![build](https://travis-ci.org/neetjn/r-localize.svg?branch=master)](https://travis-ci.org/neetjn/r-localize/)\n[![npm version](https://badge.fury.io/js/r-localize.svg)](https://badge.fury.io/js/r-localize)\n[![npm](https://img.shields.io/npm/dm/r-localize.svg)](https://www.npmjs.com/package/r-localize)\n\n[![NPM](https://nodei.co/npm/r-localize.png)](https://nodei.co/npm/r-localize/)\n\n### About\n\n**r-localize** is a localization plugin for Riot.js based off of Vue.js v-localize project.\n\n### Support\n\n| Chome  | Edge | Firefox | Opera    | Safari |\n|--------|------|---------|----------|--------|\n| 5.0+ ✔ |  ✔   | 4.0+ ✔  | 11.50+ ✔ | 5.0+ ✔ |\n\nThis project was developed using Riot.js 3, support for previous versions is not available.\n\n### Usage\n\nTo install via NPM, simply do the following:\n```sh\nnpm install r-localize\n```\nFor a quick start using jsdelivr:\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/r-localize/dist/r-localize.js\"\u003e\u003c/script\u003e\n```\nUsing the plugin is then as simple as:\n\n```js\nimport riot from 'riot'\nimport Localize from 'r-localize'\n\nconst options = {\n  debug: true,\n  default: 'en-US',\n  fallback: '-',  \n  available: ['en-US', 'es-SP']\n}\n\nconst localizations = {\n  'en-US': {\n    'header': 'international',\n    'menu': {\n      'help': 'Help'\n    }\n  },\n  'es-SP': {\n    'header': 'internacional',\n    'menu': {\n      'help': 'Ayuda'\n    }\n  }\n}\n\nlocalize = new Localize(riot, options, localizations)\n```\n\nOnce your Riot app has been mounted, the language can be changed by calling `localize.locale(args*)` from your component.\n\n```html\n\u003ccomponent\u003e\n  \u003cselect change={ locale }\u003e\n    \u003coption value=\"en-US\"\u003eEnglish\u003c/option\u003e\n    \u003coption value=\"es-SP\"\u003eSpanish\u003c/option\u003e\n  \u003c/select\u003e\n  \u003cscript\u003e\n    locale(e) {\n      this.localize.locale(e.target.value)\n    }\n  \u003c/script\u003e\n\u003c/component\u003e\n```\n\nYou can specify your localizations like so:\n\n```html\n\u003c!-- add a localized title to this element targeting en-US --\u003e\n\u003ch1 data-is=\"localize\" t={{ i: 'header', attr: 'title' }} /\u003e\n\u003c!-- replace this element's text with localized item --\u003e\n\u003ch1 data-is=\"localize\" t=\"menu.help\"\u003e\n```\n\nAlternatively, you can fetch your current localization by calling `locale` without any arguments.\n\n```html\n\u003ch1\u003eCurrent Locale: { localize.locale() }\u003c/h1\u003e\n```\n\nFor fetching a specific locale item programatically within a component method:\n\n```js\n\u003ch1\u003eTranslated Item: { localize.translate('header', 'es-SP') }\u003c/h1\u003e\n```\n\n### Configuration\n\nThe plugin takes 5 options,\n\n\u003e **`*available`**: List of available localizations.\n\n```js\n['en-US', 'es-SP', 'pr-BR', {\n  locale: 'ar-MS',\n  orientation: 'rtl'\n}]\n```\n\n\u003e **`*debug`**: Spit info, warnings and errors to console.\n\n\u003e **`*default`**: Default locale key to target.\n\n\u003e **`fallbackContent`**: Use the existing node's text content if enabled and requested localization is not found. \n\n\u003e **`*fallback`**: Default text to show if localization for current language not found.\n\n\u003e **`webStore`**: If the mixin is accessed within a web context and option `webStore` is enabled, mixin will store the locale in local storage for the next visit.\n\n### Locale Options\n\nLocale configuration currently supports the following options,\n\n\u003e **`orientation`**: Text direction of target element, useful for orientation of script languages.\n\n\u003e **`fontFamily`**: Font family to change to. Re: [https://www.w3schools.com/jsref/prop_style_fontfamily.asp]()\n\n### Contributors\n\n* **John Nolette** (john@neetgroup.net)\n\nContributing guidelines can be found [here](https://github.com/neetjn/r-localize/blob/master/CONTRIBUTING.md).\n\n---\n\nCopyright (c) 2018 John Nolette Licensed under the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneetjn%2Fr-localize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneetjn%2Fr-localize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneetjn%2Fr-localize/lists"}