Skip to content
This repository has been archived by the owner on Jul 12, 2021. It is now read-only.

Commit

Permalink
Use Partial for Translations type
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelmeuli committed Jan 23, 2020
1 parent ca6a52c commit 06a345e
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 104 deletions.
6 changes: 3 additions & 3 deletions src/main/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import translationsUk from "./translations/uk";
import translationsZh from "./translations/zh";
import translationsZhTw from "./translations/zhTw";

const ALL_TRANSLATIONS: Record<string, Translations> = {
const ALL_TRANSLATIONS: Record<string, Partial<Translations>> = {
de: translationsDe,
el: translationsEl,
en: translationsEn,
Expand All @@ -28,7 +28,7 @@ const ALL_TRANSLATIONS: Record<string, Translations> = {
zh: translationsZh,
"zh-TW": translationsZhTw,
};
let translations: Translations; // String translations for langNoRegion
let translations: Partial<Translations>; // String translations for langNoRegion

const FALLBACK_LANG = "en";
let systemLang;
Expand Down Expand Up @@ -115,6 +115,6 @@ export function translate(
/**
* Return all translations for the detected language
*/
export function getTranslations(): Translations {
export function getTranslations(): Partial<Translations> {
return translations;
}
2 changes: 1 addition & 1 deletion src/main/i18n/translations/de.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsDe: Translations = {
const translationsDe: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Über {appName}",
"bring-all-to-front": "Alle nach vorne bringen",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/el.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsEl: Translations = {
const translationsEl: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Πληροφορίες για το {appName}",
"bring-all-to-front": "Επαναφορά όλων στο προσκήνιο",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/es.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsEs: Translations = {
const translationsEs: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Acerca de {appName}",
"bring-all-to-front": "Traer todo al frente",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/fr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsFr: Translations = {
const translationsFr: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "À propos de {appName}",
"bring-all-to-front": "Tout ramener au premier plan",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/is.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsIs: Translations = {
const translationsIs: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Um {appName}",
"bring-all-to-front": "Færa allt í forgrunn",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/pt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsPt: Translations = {
const translationsPt: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Acerca de {appName}",
"bring-all-to-front": "Passar tudo para a frente",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/tr.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsTr: Translations = {
const translationsTr: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "{appName} Hakkında",
"bring-all-to-front": "Tümünü Öne Çıkart",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/uk.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsUk: Translations = {
const translationsUk: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "Про {appName}",
"bring-all-to-front": "Показати всі вікна",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/zh.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsZh: Translations = {
const translationsZh: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "关于{appName}",
"bring-all-to-front": "全部置顶",
Expand Down
2 changes: 1 addition & 1 deletion src/main/i18n/translations/zhTw.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Translations } from "../../../shared/types";

// prettier-ignore
const translationsZhTw: Translations = {
const translationsZhTw: Partial<Translations> = {
// Menu (defined by macOS)
"about-app": "關於{appName}",
"bring-all-to-front": "將此程式所有視窗移至最前",
Expand Down
182 changes: 91 additions & 91 deletions src/shared/types.ts
Original file line number Diff line number Diff line change
@@ -1,117 +1,117 @@
// prettier-ignore
export interface Translations {
// Menu (defined by macOS)
"about-app"?: string,
"bring-all-to-front"?: string,
"close"?: string,
"copy"?: string,
"cut"?: string,
"edit"?: string,
"file"?: string,
"help"?: string,
"hide-app"?: string,
"hide-others"?: string,
"minimize"?: string,
"paste"?: string,
"preferences"?: string,
"quit-app"?: string,
"redo"?: string,
"select-all"?: string,
"show-all"?: string,
"speech"?: string,
"start-speaking"?: string,
"stop-speaking"?: string,
"undo"?: string,
"view"?: string,
"window"?: string,
"zoom"?: string,
"about-app": string,
"bring-all-to-front": string,
"close": string,
"copy": string,
"cut": string,
"edit": string,
"file": string,
"help": string,
"hide-app": string,
"hide-others": string,
"minimize": string,
"paste": string,
"preferences": string,
"quit-app": string,
"redo": string,
"select-all": string,
"show-all": string,
"speech": string,
"start-speaking": string,
"stop-speaking": string,
"undo": string,
"view": string,
"window": string,
"zoom": string,

// Menu (app-specific)
"export"?: string,
"export-to-format"?: string,
"import"?: string,
"import-from-format"?: string,
"license"?: string,
"lock-diary"?: string,
"next-day"?: string,
"next-month"?: string,
"previous-day"?: string,
"previous-month"?: string,
"privacy-policy"?: string,
"statistics"?: string;
"website"?: string,
"export": string,
"export-to-format": string,
"import": string,
"import-from-format": string,
"license": string,
"lock-diary": string,
"next-day": string,
"next-month": string,
"previous-day": string,
"previous-month": string,
"privacy-policy": string,
"statistics": string;
"website": string,

// Theme
"auto"?: string,
"dark"?: string,
"light"?: string,
"theme"?: string,
"auto": string,
"dark": string,
"light": string,
"theme": string,

// Calendar
"today"?: string,
"today": string,

// Editor
"add-a-title"?: string,
"bold"?: string,
"bullets"?: string,
"italic"?: string,
"list"?: string,
"write-something"?: string,
"add-a-title": string,
"bold": string,
"bullets": string,
"italic": string,
"list": string,
"write-something": string,

// Search
"clear"?: string,
"no-results"?: string,
"no-title"?: string,
"search"?: string,
"clear": string,
"no-results": string,
"no-title": string,
"search": string,

// Preferences
"allow-future-entries"?: string,
"diary-entries"?: string,
"no"?: string,
"reset-diary"?: string,
"reset-diary-confirm"?: string,
"reset-diary-msg"?: string,
"allow-future-entries": string,
"diary-entries": string,
"no": string,
"reset-diary": string,
"reset-diary-confirm": string,
"reset-diary-msg": string,

// Password and directory
"change-directory"?: string,
"change-password"?: string,
"choose-password"?: string,
"decryption-error"?: string,
"diary-file"?: string,
"file-exists"?: string,
"move-error-msg"?: string,
"move-error-title"?: string,
"move-file"?: string,
"new-password"?: string,
"password"?: string,
"passwords-no-match"?: string,
"repeat-new-password"?: string,
"repeat-password"?: string,
"select-directory"?: string,
"set-password"?: string,
"unlock"?: string,
"wrong-password"?: string,
"change-directory": string,
"change-password": string,
"choose-password": string,
"decryption-error": string,
"diary-file": string,
"file-exists": string,
"move-error-msg": string,
"move-error-title": string,
"move-file": string,
"new-password": string,
"password": string,
"passwords-no-match": string,
"repeat-new-password": string,
"repeat-password": string,
"select-directory": string,
"set-password": string,
"unlock": string,
"wrong-password": string,

// Statistics
"total-entries"?: string,
"entries-per-week"?: string,
"streak-best"?: string,
"streak-current"?: string,
"total-words"?: string,
"words-per-entry"?: string,
"total-entries": string,
"entries-per-week": string,
"streak-best": string,
"streak-current": string,
"total-words": string,
"words-per-entry": string,

// Import
"import-error-msg"?: string,
"import-error-title"?: string,
"import-instructions-day-one"?: string,
"import-instructions-jrnl"?: string,
"import-instructions-mini-diary"?: string,
"start-import"?: string,
"import-error-msg": string,
"import-error-title": string,
"import-instructions-day-one": string,
"import-instructions-jrnl": string,
"import-instructions-mini-diary": string,
"start-import": string,

// Export
"export-error-msg"?: string,
"export-error-title"?: string,
"export-error-msg": string,
"export-error-title": string,

// Other
"loading"?: string,
"loading": string,
}

0 comments on commit 06a345e

Please sign in to comment.