add translation keys (#246)
* Fix i18n tsc issue "t" can return null by default. This was already disabled in the config, but it had no effect on tsc. * Fix translation in "DefaultNavBar" key was missing and since this is a constant the translation wouldn't update in case the language got changed after first load. * Enable typing for i18n translation keys * Add translation keys
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
import { t } from 'i18next';
|
||||
|
||||
export const isWithinLastXMillis = (date: Date, timeMS: number) => {
|
||||
const timeDifference = Date.now() - date.getTime();
|
||||
@@ -54,11 +55,11 @@ export const getUploadDateString = (date: Date | number) => {
|
||||
: '';
|
||||
|
||||
if (wasUploadedToday) {
|
||||
return `Today at ${timeString}`;
|
||||
return t('global.date.label.today_at', { timeString });
|
||||
}
|
||||
|
||||
if (wasUploadedYesterday) {
|
||||
return `Yesterday at ${timeString}`;
|
||||
return t('global.date.label.yesterday_at', { timeString });
|
||||
}
|
||||
|
||||
return uploadDate.toLocaleDateString(undefined, {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
import { t } from 'i18next';
|
||||
|
||||
export const ISOLanguages = [
|
||||
{ code: 'all', name: 'All', nativeName: 'All' },
|
||||
@@ -80,7 +81,7 @@ export function langCodeToName(code: string): string {
|
||||
const whereToCut = code.indexOf('-') !== -1 ? code.indexOf('-') : code.length;
|
||||
|
||||
const proccessedCode = code.toLocaleLowerCase().substring(0, whereToCut);
|
||||
let result = `language with code: ${code}`;
|
||||
let result = t('global.language.label.language_with_code', { code });
|
||||
|
||||
for (let i = 0; i < ISOLanguages.length; i++) {
|
||||
if (ISOLanguages[i].code === proccessedCode || ISOLanguages[i].code === code.toLocaleLowerCase()) {
|
||||
|
||||
Reference in New Issue
Block a user