{"id":20381254,"url":"https://github.com/drago-ex/translator","last_synced_at":"2025-04-12T08:51:42.610Z","repository":{"id":56971775,"uuid":"44368722","full_name":"drago-ex/translator","owner":"drago-ex","description":":earth_africa: Drago Extension for Nette Framework providing localization support with a custom Translator service and DI integration.","archived":false,"fork":false,"pushed_at":"2025-01-28T07:35:07.000Z","size":183,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T14:18:19.468Z","etag":null,"topics":["nette","translator"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/drago-ex.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","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":"2015-10-16T07:15:22.000Z","updated_at":"2025-01-28T07:34:23.000Z","dependencies_parsed_at":"2024-01-12T10:11:12.057Z","dependency_job_id":"3d541c59-ec23-44cc-a7a8-cde2718f8126","html_url":"https://github.com/drago-ex/translator","commit_stats":{"total_commits":235,"total_committers":3,"mean_commits":78.33333333333333,"dds":"0.012765957446808529","last_synced_commit":"cba86fe3c91583ab852c141fd53e0bf51725e61a"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Ftranslator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Ftranslator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Ftranslator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drago-ex%2Ftranslator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drago-ex","download_url":"https://codeload.github.com/drago-ex/translator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248543882,"owners_count":21121838,"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":["nette","translator"],"created_at":"2024-11-15T02:12:38.268Z","updated_at":"2025-04-12T08:51:42.605Z","avatar_url":"https://github.com/drago-ex.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Drago Translator\r\nSimple and lightweight translator for Nette Framework, providing localization support using NEON translation files.\r\n\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://raw.githubusercontent.com/drago-ex/translator/master/license.md)\r\n[![PHP version](https://badge.fury.io/ph/drago-ex%2Ftranslator.svg)](https://badge.fury.io/ph/drago-ex%2Ftranslator)\r\n[![Tests](https://github.com/drago-ex/translator/actions/workflows/tests.yml/badge.svg)](https://github.com/drago-ex/translator/actions/workflows/tests.yml)\r\n[![Coding Style](https://github.com/drago-ex/translator/actions/workflows/coding-style.yml/badge.svg)](https://github.com/drago-ex/translator/actions/workflows/coding-style.yml)\r\n[![CodeFactor](https://www.codefactor.io/repository/github/drago-ex/translator/badge)](https://www.codefactor.io/repository/github/drago-ex/translator)\r\n[![Coverage Status](https://coveralls.io/repos/github/drago-ex/translator/badge.svg?branch=master)](https://coveralls.io/github/drago-ex/translator?branch=master)\r\n\r\n## Technology\r\n- PHP 8.3 or higher\r\n- composer\r\n\r\n## Installation\r\n```\r\ncomposer require drago-ex/translator\r\n```\r\n\r\n## Extension registration\r\nRegister the `Drago\\Localization\\DI\\TranslatorExtension` in your Nette project by adding the following\r\nconfiguration to your `neon` file:\r\n```neon\r\nextensions:\r\n\t- Drago\\Localization\\DI\\TranslatorExtension(translateDir: %appDir%/locale)\r\n```\r\n\r\n## Use in the presenter\r\nTo use the translator in your presenter, add the `TranslatorAdapter` trait:\r\n```php\r\nuse Drago\\Localization\\TranslatorAdapter\r\n```\r\n\r\n## Accessing the Current Language\r\nYou can access the currently set language using the following property:\r\n```php\r\n$this-\u003elang;\r\n```\r\n\r\n## Get Translator Instance\r\nTo get the translator instance, use the `getTranslator` method:\r\n```php\r\n$this-\u003egetTranslator();\r\n```\r\n\r\n## Translation File Format\r\nTranslation files should be written in the NEON format. For example:\r\n```neon\r\n\"Hello, world!\": \"Hello, world!\"\r\n```\r\n\r\n## Using Translations in Templates\r\nYou can translate strings directly in your Latte templates using the following syntax:\r\n```latte\r\n{_\"Hello, world!\"}\r\n\r\n{* Using a filter for translation *}\r\n{$var|translate}\r\n```\r\n\r\n## Translating Forms\r\nTo use translations in forms, simply set the translator for the form:\r\n```php\r\n$form-\u003esetTranslator($this-\u003egetTranslator());\r\n```\r\n\r\n## Route Configuration for Language Switching\r\nSet up your routes to support language prefixes. For example, you can define routes with language codes:\r\n```php\r\n$router-\u003eaddRoute('[\u003clang=en cs|en\u003e/]\u003cpresenter\u003e/\u003caction\u003e', 'Presenter:action');\r\n```\r\n\r\n## Switching Languages in Templates\r\nTo switch between languages in your templates, you can use n:href to pass the selected language:\r\n```latte\r\n\u003ca n:href=\"this, 'lang' =\u003e 'cs'\"\u003eCzech\u003c/a\u003e\r\n\u003ca n:href=\"this, 'lang' =\u003e 'en'\"\u003eEnglish\u003c/a\u003e\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrago-ex%2Ftranslator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrago-ex%2Ftranslator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrago-ex%2Ftranslator/lists"}