Skip to content

Commit

Permalink
Renamed localization variable on window
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanhao Li authored and ifox committed Mar 2, 2020
1 parent f92e93c commit 55ed36b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion frontend/js/plugins/A17Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ const A17Config = {
Vue.prototype.$http = axios

Vue.prototype.$trans = function (key, defaultValue) {
return get(window[process.env.VUE_APP_NAME].lang, key, defaultValue)
return get(window[process.env.VUE_APP_NAME].twillLocalization.lang, key, defaultValue)
}

axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'
Expand Down
11 changes: 8 additions & 3 deletions src/Http/ViewComposers/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ public function compose(View $view)
{
$currentLang = Lang::get('twill::lang', [], App::getLocale());
$fallbackLang = Lang::get('twill::lang', [], config('app.fallback_locale', 'en'));
$lang = array_replace_recursive($fallbackLang, $currentLang);

$view->with(['lang' => $lang]);
$lang = array_replace_recursive($currentLang, $fallbackLang);
$twillLocalization = [
'locale' => App::getLocale(),
'fallback_locale' => config('app.fallback_locale', 'en'),
'lang' => $lang
];

$view->with(['twillLocalization' => $twillLocalization]);
}
}
2 changes: 1 addition & 1 deletion views/layouts/main.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
window['{{ config('twill.js_namespace') }}'].STORE.medias = {};
window['{{ config('twill.js_namespace') }}'].STORE.medias.types = [];
window['{{ config('twill.js_namespace') }}'].STORE.languages = {!! json_encode(getLanguagesForVueStore($form_fields ?? [], $translate ?? false)) !!};
window['{{ config('twill.js_namespace') }}'].lang = {!! json_encode($lang) !!};
window['{{ config('twill.js_namespace') }}'].twillLocalization = {!! json_encode($twillLocalization) !!};
@if (config('twill.enabled.media-library'))
window['{{ config('twill.js_namespace') }}'].STORE.medias.types.push({
Expand Down

0 comments on commit 55ed36b

Please sign in to comment.