{"id":18310304,"url":"https://github.com/torann/jquery-translation","last_synced_at":"2025-04-09T11:44:26.174Z","repository":{"id":58238545,"uuid":"80765068","full_name":"Torann/jquery-translation","owner":"Torann","description":"A jQuery plugin which enables you to translate text on the client side.","archived":false,"fork":false,"pushed_at":"2018-05-29T20:41:05.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T05:43:42.805Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Torann.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":"2017-02-02T20:20:42.000Z","updated_at":"2018-10-22T19:46:27.000Z","dependencies_parsed_at":"2022-08-31T00:30:37.551Z","dependency_job_id":null,"html_url":"https://github.com/Torann/jquery-translation","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torann%2Fjquery-translation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torann%2Fjquery-translation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torann%2Fjquery-translation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Torann%2Fjquery-translation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Torann","download_url":"https://codeload.github.com/Torann/jquery-translation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248033550,"owners_count":21036811,"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-05T16:14:01.655Z","updated_at":"2025-04-09T11:44:26.143Z","avatar_url":"https://github.com/Torann.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jQuery Translation\n\njQuery Translation is a [jQuery](http://jquery.com/) plugin which enables you to translate text on the client side.\n\n## Getting Started\n\nYou can install the plugin using Bower:\n\n```bash\nbower install jquery-trans\n```\n\n## Uses a predefined dictionary\n\nYou can get or set the dictionary the plugin uses by calling `$.setTranslator`. It is a object made by key-value pairs, with the original sentence or string id as key, and the translated sentence as value (or a translating function, see below).\n\n```javascript\n$.setTranslator({\n    'Unable to load page': 'Unable to load page',\n});\n```\n\n### How I use this in Laravel\n\nMost of my projects have a partial called `translations.blade.php` that uses Laravel's translation system to set the value and is included at the end of the primary layout. My partial looks like this:\n\n```php\n\u003cscript type=\"text/javascript\"\u003e\n$.setTranslator({!! json_encode([\n    // Buttons\n    'buttons.OK' =\u003e trans('buttons.OK'),\n    'buttons.Cancel' =\u003e trans('buttons.Cancel'),\n    'buttons.Back' =\u003e trans('navigation.Back'),\n    'buttons.Submit' =\u003e trans('buttons.Submit'),\n    'buttons.Next' =\u003e trans('buttons.Next'),\n    'buttons.Edit' =\u003e trans('buttons.Edit'),\n    'buttons.Update' =\u003e trans('buttons.Update'),\n    'buttons.Create' =\u003e trans('buttons.Create'),\n    'buttons.Delete' =\u003e trans('buttons.Delete'),\n    'buttons.Report' =\u003e trans('buttons.Report'),\n    'buttons.Share' =\u003e trans('buttons.Share'),\n    'buttons.Post' =\u003e trans('buttons.Post'),\n\n    // Dates\n    'date.now' =\u003e trans('date.now'),\n    'date.pluralize_year' =\u003e trans('date.pluralize_year'),\n    'date.pluralize_month' =\u003e trans('date.pluralize_month'),\n    'date.pluralize_day' =\u003e trans('date.pluralize_day'),\n    'date.pluralize_hour' =\u003e trans('date.pluralize_hour'),\n    'date.pluralize_minute' =\u003e trans('date.pluralize_minute'),\n    'date.pluralize_second' =\u003e trans('date.pluralize_second'),\n]) !!});\n\u003c/script\u003e\n```\n\n## Replaces parameters in translations\n\nBecause the order of words may change between languages, the use of parameters is necessary. A parameter is indicated by a `:` followed by an identifier in the sentences. Give an associative map as second argument to the translator function, which contains identifiers as keys and replacement texts as values.\n\n```javascript\n$.trans('Welcome :name to the new :place', {\n    name: 'Jane Doe',\n    place: 'Burger Hut'\n})\n```\n\n## API\n\n```javascript\n// Simple string translation\n$.trans(key, opt)\n\n// Retrieve the line for a given \"count\"\n$.trans_choice(key, count);\n\n// Sets translations\n$.setTranslator();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorann%2Fjquery-translation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftorann%2Fjquery-translation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftorann%2Fjquery-translation/lists"}