Skip to content

Commit be2e227

Browse files
committed
fix: load php translations
1 parent c6579c0 commit be2e227

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/index.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,33 @@ function setLanguage({ lang, messages }: LanguageInterface): string {
137137
/**
138138
* It resolves the language file or data, from direct data, require or Promise.
139139
*/
140-
function resolveLang(callable: Function, lang: string): Promise<LanguageJsonFileInterface> {
141-
console.log('HAS PHP', process.env.LARAVEL_VUE_I18N_HAS_PHP);
142-
140+
async function resolveLang(callable: Function, lang: string) {
141+
const hasPhpTranslations = process.env.LARAVEL_VUE_I18N_HAS_PHP;
143142
const data = callable(lang)
144143

145144
if (data instanceof Promise) {
146-
return data
145+
if (hasPhpTranslations) {
146+
const phpLang = await callable(`php_${lang}`);
147+
const jsonLang = await data;
148+
149+
return new Promise((resolve) => resolve({
150+
default: {
151+
...phpLang,
152+
...jsonLang
153+
}
154+
}));
155+
}
156+
157+
return data;
158+
}
159+
160+
if (hasPhpTranslations) {
161+
return new Promise((resolve) => resolve({
162+
default: {
163+
...data,
164+
...(callable(`php_${lang}`)),
165+
}
166+
}));
147167
}
148168

149169
return new Promise((resolve) => resolve({ default: data }))

src/mix.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ mix.extend('i18n', class extends Component {
3535
};
3636

3737
if (hasPhpTranslations(this.langPath)) {
38-
console.log('has translations');
3938
config.plugins.push(new EnvironmentPlugin({
4039
'LARAVEL_VUE_I18N_HAS_PHP': true,
4140
}));

0 commit comments

Comments
 (0)