diff --git a/src/pages.tsx b/src/pages.tsx index fa6388c..1d26f56 100644 --- a/src/pages.tsx +++ b/src/pages.tsx @@ -44,6 +44,7 @@ import { UserPassUserEdit } from "./ui/pages/Access/Auth/userpass/UserPassUserEd import { UserPassUserNew } from "./ui/pages/Access/Auth/userpass/UserPassUserNew"; import { UserPassUserView } from "./ui/pages/Access/Auth/userpass/UserPassUserView"; import { UserPassUsersList } from "./ui/pages/Access/Auth/userpass/UserPassUsersList"; +import { InternalTranslateTool } from "./ui/pages/InternalTranslateTool"; export const Main = () => ( @@ -54,6 +55,7 @@ export const Main = () => ( + diff --git a/src/ui/pages/InternalTranslateTool.tsx b/src/ui/pages/InternalTranslateTool.tsx new file mode 100644 index 0000000..d144873 --- /dev/null +++ b/src/ui/pages/InternalTranslateTool.tsx @@ -0,0 +1,122 @@ +import { Component, JSX, createRef } from "preact"; +import i18next from "i18next"; + +import { InputWithTitle } from "../elements/InputWithTitle" + +// @ts-ignore +import translations from "../../translations/index.mjs"; +import { CodeEditor } from "../elements/CodeEditor"; +import { getObjectKeys } from "../../utils"; +// ts-unignore + +function SplitView(props: { children: JSX.Element | JSX.Element[] }) { + return ( +
+ {props.children} +
+ ) +} + + +const languageIDs = Object.getOwnPropertyNames(translations); + +class LanguageSelector extends Component<{ onLanguageChange: (id: string) => void }> { + selectRef = createRef() + render() { + return ( + + ) + } +} + +function arrayDiff(a: string[], b: string[]): {missing: string[], extra: string[]} { + return { + missing: a.filter(x => !b.includes(x)), + extra: b.filter(x => !a.includes(x)), + }; +} + + +type InternalTranslateToolState = { + sourceLangID: string; + targetLangID: string; + targetTranslationData: Record +} + +export class InternalTranslateTool extends Component { + constructor() { + super() + this.setState({ + sourceLangID: "en", + targetLangID: "en", + }) + } + + render() { + let diff = arrayDiff( + getObjectKeys(translations[this.state.sourceLangID]), + getObjectKeys(this.state.targetTranslationData || translations[this.state.targetLangID]) + ); + + return ( + <> +

Internal Translation Tool

+ + + { this.setState({ sourceLangID: id }) }} /> + + + + { + this.setState({ + targetLangID: id, + targetTranslationData: translations[id] + }) + }} /> + + +
+ +

Source Language

+ + { }} + /> + +

Target Language

+ +

Missing from target language:

+
    + {diff.missing.map((value) =>
  • - {value}
  • )} +
+ +

Extra Keys (maybe deprecated, renamed or no longer exists, check git log)

+
    + {diff.extra.map((value) =>
  • - {value}
  • )} +
+ + { + this.setState({ + targetTranslationData: JSON.parse(code) + }) + }} + /> + + ) + } +} \ No newline at end of file