Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/devture/silex-translation-bundle
Silex bundle that allows .json files to be translated between multiple languages.
https://github.com/devture/silex-translation-bundle
Last synced: 13 days ago
JSON representation
Silex bundle that allows .json files to be translated between multiple languages.
- Host: GitHub
- URL: https://github.com/devture/silex-translation-bundle
- Owner: devture
- License: bsd-3-clause
- Created: 2017-02-20T11:18:46.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-03-17T18:15:42.000Z (over 7 years ago)
- Last Synced: 2024-04-10T04:11:26.808Z (7 months ago)
- Language: PHP
- Size: 39.1 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Description
Finds all `{sourceLanguage}.json` files (example: `en.json`) in a given base directory (`base_path`)
and allows these files to be translated to all given languages (`locales`).A `{targetLanguage}.json` file is generated and saved next to `{sourceLanguage}.json` for each locale, whenever the translations for it are saved.
A `{targetLanguage}.json.hash` file is also saved in the same directory.
It contains "hints" telling the translation system which source translation string a given translation is derived from.
This is so that a translation can be considered outdated if the source translation string changes.
At this moment, such outdated translations are considered new and untranslated.# Installation
## Permissions
Since the translation system needs to save translation files in the project, we need to grant file-writing privileges
to the web server user.Example:
$ find /srv/http/my-project/src -type d -name translations | xargs chown :http
$ find /srv/http/my-project/src -type d -name translations | xargs chmod g+w## Configuration
TranslationBundle config:
"TranslationBundle": {
"source_language_locale_key": "en",
"base_path": "%app_base_path%",
"locales": "%locales%"
}TranslationBundle config example:
"TranslationBundle": {
"source_language_locale_key": "en",
"base_path": "/srv/http/my-project/src",
"locales": {
"en": {"key": "en", "name": "English"},
"bg": {"key": "bg", "name": "Bulgarian"},
"ja": {"key": "ja", "name": "Japanese"}
}
}## Initialization
Only set-up during debug to protect the production environment:
if ($app['debug']) {
$app->register(new \Devture\Bundle\TranslationBundle\ServicesProvider('devture_translation', $app['config']['TranslationBundle']));
$app->mount('/admin/{locale}/translation/', $app['devture_translation.controllers_provider.management']);
$app['devture_user.access_control']->requireRoleForRoutePrefix('devture_translation.', 'devture_translation');
}The main route would be `devture_translation.manage` (assuming the `devture_translation` namespace was used, as done above).