diff options
author | Chocobozzz <me@florianbigard.com> | 2018-06-06 17:37:13 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-06-06 17:37:13 +0200 |
commit | 74b7c6d48e9ca377fe938c8134ed74b612e62ba0 (patch) | |
tree | cb848dec054a71669fef5ea3986bdd0d2c354248 /client/src/app/app.module.ts | |
parent | 7ce44a74a3b052190cfacd4bd5ee6b92cfc620ac (diff) | |
download | PeerTube-74b7c6d48e9ca377fe938c8134ed74b612e62ba0.tar.gz PeerTube-74b7c6d48e9ca377fe938c8134ed74b612e62ba0.tar.zst PeerTube-74b7c6d48e9ca377fe938c8134ed74b612e62ba0.zip |
Little i18n refractoring
Diffstat (limited to 'client/src/app/app.module.ts')
-rw-r--r-- | client/src/app/app.module.ts | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index e60a74cc0..51e354378 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts | |||
@@ -16,8 +16,8 @@ import { MenuComponent } from './menu' | |||
16 | import { SharedModule } from './shared' | 16 | import { SharedModule } from './shared' |
17 | import { SignupModule } from './signup' | 17 | import { SignupModule } from './signup' |
18 | import { VideosModule } from './videos' | 18 | import { VideosModule } from './videos' |
19 | import { buildFileLocale, getDefaultLocale } from '../../../shared/models/i18n' | 19 | import { buildFileLocale, getCompleteLocale, getDefaultLocale, isDefaultLocale } from '../../../shared/models/i18n' |
20 | import { environment } from '../environments/environment' | 20 | import { getDevLocale, isOnDevLocale } from '@app/shared/i18n/i18n-utils' |
21 | 21 | ||
22 | export function metaFactory (serverService: ServerService): MetaLoader { | 22 | export function metaFactory (serverService: ServerService): MetaLoader { |
23 | return new MetaStaticLoader({ | 23 | return new MetaStaticLoader({ |
@@ -67,17 +67,17 @@ export function metaFactory (serverService: ServerService): MetaLoader { | |||
67 | { | 67 | { |
68 | provide: TRANSLATIONS, | 68 | provide: TRANSLATIONS, |
69 | useFactory: (locale) => { | 69 | useFactory: (locale) => { |
70 | // On dev mode, test locales | 70 | // On dev mode, test localization |
71 | if (environment.production === false && window.location.search === '?lang=fr') { | 71 | if (isOnDevLocale()) { |
72 | return require(`raw-loader!../locale/target/angular_fr.xml`) | 72 | locale = getDevLocale() |
73 | return require(`raw-loader!../locale/target/angular_${locale}.xml`) | ||
73 | } | 74 | } |
74 | 75 | ||
75 | const fileLocale = buildFileLocale(locale) | ||
76 | |||
77 | // Default locale, nothing to translate | 76 | // Default locale, nothing to translate |
78 | const defaultFileLocale = buildFileLocale(getDefaultLocale()) | 77 | const completeLocale = getCompleteLocale(locale) |
79 | if (fileLocale === defaultFileLocale) return '' | 78 | if (isDefaultLocale(completeLocale)) return '' |
80 | 79 | ||
80 | const fileLocale = buildFileLocale(locale) | ||
81 | return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`) | 81 | return require(`raw-loader!../locale/target/angular_${fileLocale}.xml`) |
82 | }, | 82 | }, |
83 | deps: [ LOCALE_ID ] | 83 | deps: [ LOCALE_ID ] |