Skip to content

Commit

Permalink
add basic language configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
adammatysiak committed Feb 16, 2018
1 parent 0d0810d commit 9efdf6d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions config/translation-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
// ...
),

/**
* Basic language used by translator.
*/
'basic_lang' => 'en',

/**
* Export translations with keys output alphabetically.
*/
Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ Configuration
| delete_enabled | Enable deletion of translations | true |
| exclude_groups | Exclude specific file groups (like validation, pagination, routes etc.) | [] |
| exclude_langs | Exclude specific langs and directories (like vendor and en, etc.) | [] |
| basic_lang | Basic language used by translator. | 'en' |
| sort_keys | Export translations with keys output alphabetically. | false |
| highlight_locale_marked | Highlight lines with locale marked as not translated. | false |
| live_translation_enabled | Enable live translation of content. | false |
Expand Down
7 changes: 4 additions & 3 deletions src/Translator.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,14 @@ public function transEditable($key, array $replace = [], $locale = null, $fallba
if (!$locale) {
$locale = \App::getLocale();
}
$englishTranslation = parent::get($key, $replace, 'en', $fallback);
$basicLocale = config('translation-manager.basic_lang', 'en');
$basicTranslation = parent::get($key, $replace, $basicLocale, $fallback);

/**
* we need escaped versions in order to show them as title and value;
* real translation is displayed unescaped
*/
$escapedEnglishTranslation = htmlspecialchars($englishTranslation, ENT_QUOTES, 'UTF-8', false);
$escapedBasicTranslation = htmlspecialchars($basicTranslation, ENT_QUOTES, 'UTF-8', false);
$escapedCurrentTranslation = htmlspecialchars($translation, ENT_QUOTES, 'UTF-8', false);

return '<span class=\'editable locale-'. $locale . '\'' .
Expand All @@ -90,7 +91,7 @@ public function transEditable($key, array $replace = [], $locale = null, $fallba
' data-type=\'textarea\'' .
' data-pk=\'dummy\'' .
' data-value=\'' . $escapedCurrentTranslation . '\'' .
' data-title=\'' . $escapedEnglishTranslation . ' (en -> ' . $locale . ')\'>' .
' data-title=\'' . $escapedEnglishTranslation . ' (' . $basicLocale . ' -> ' . $locale . ')\'>' .
$translation . '</span>';
}

Expand Down

0 comments on commit 9efdf6d

Please sign in to comment.