Skip to content

Commit e132726

Browse files
committed
style: fixes
1 parent f11d8ae commit e132726

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

src/index.ts

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ function loadLanguage(lang: string, dashLangTry: boolean = false): void {
4949
const loadedLang: LanguageInterface = loaded.find((row) => row.lang === lang)
5050

5151
if (loadedLang) {
52-
setLanguage(loadedLang);
52+
setLanguage(loadedLang)
5353

54-
return;
54+
return
5555
}
5656

57-
const { default: messages } = resolveLang(options.resolve, lang);
57+
const { default: messages } = resolveLang(options.resolve, lang)
5858

59-
applyLanguage(lang, messages, dashLangTry, loadLanguage);
59+
applyLanguage(lang, messages, dashLangTry, loadLanguage)
6060
}
6161

6262
/**
@@ -88,11 +88,11 @@ function applyLanguage(
8888
return callable(
8989
lang.replace(/[-_]/g, (char) => (char === '-' ? '_' : '-')),
9090
true
91-
);
91+
)
9292
}
9393

9494
if (lang !== options.fallbackLang) {
95-
return callable(options.fallbackLang);
95+
return callable(options.fallbackLang)
9696
}
9797
}
9898

@@ -176,16 +176,22 @@ function setLanguage({ lang, messages }: LanguageInterface): string {
176176
/**
177177
* It resolves the language file or data, from direct data, syncrone.
178178
*/
179-
function resolveLang(callable: Function, lang: string, data: { [key: string]: string } = {}): LanguageJsonFileInterface {
180-
if (! Object.keys(data).length) {
179+
function resolveLang(
180+
callable: Function,
181+
lang: string,
182+
data: { [key: string]: string } = {}
183+
): LanguageJsonFileInterface {
184+
if (!Object.keys(data).length) {
181185
data = avoidException(callable, lang)
182186
}
183187

184188
if (hasPhpTranslations(isServer)) {
185-
return { default: {
186-
...data,
187-
...avoidException(callable, `php_${lang}`)
188-
} }
189+
return {
190+
default: {
191+
...data,
192+
...avoidException(callable, `php_${lang}`)
193+
}
194+
}
189195
}
190196

191197
return { default: data }
@@ -197,8 +203,8 @@ function resolveLang(callable: Function, lang: string, data: { [key: string]: st
197203
async function resolveLangAsync(callable: Function, lang: string): Promise<LanguageJsonFileInterface> {
198204
let data = avoidException(callable, lang)
199205

200-
if (! (data instanceof Promise)) {
201-
return resolveLang(callable, lang, data);
206+
if (!(data instanceof Promise)) {
207+
return resolveLang(callable, lang, data)
202208
}
203209

204210
if (hasPhpTranslations(isServer)) {

src/utils/has-php-translations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export function hasPhpTranslations(isServer: boolean): boolean {
2-
return isServer || checkProcessEnv() || checkImportMeta();
2+
return isServer || checkProcessEnv() || checkImportMeta()
33
}
44

55
function checkProcessEnv(): boolean {
6-
return typeof process !== 'undefined' && process.env?.LARAVEL_VUE_I18N_HAS_PHP ? true : false;
6+
return typeof process !== 'undefined' && process.env?.LARAVEL_VUE_I18N_HAS_PHP ? true : false
77
}
88

99
function checkImportMeta(): boolean {
1010
/** @ts-ignore */
11-
return import.meta.env.VITE_LARAVEL_VUE_I18N_HAS_PHP ? true : false;
11+
return import.meta.env.VITE_LARAVEL_VUE_I18N_HAS_PHP ? true : false
1212
}

0 commit comments

Comments
 (0)