Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ A relational algebra calculator
* Insert a string for every language key there is (pay attention to {{variables}} as they must stay untouched)
* When finished, execute the script `writeLanguageFiles.py` which generates the json files based on the csv
* In `src/calc2/i18n.tsx` add an import for this file as well as initializing it in the i18n init function (see other languages for examples)
* Add a new dropdown entry to `src/calc2/calculator.entry.tsx` and `src/calc2/calculator.entry.tsx`
* Add a new dropdown entry to `src/calc2/components/calculator.tsx`, `src/calc2/components/navigation.tsx` and `src/calc2/components/navigation-mobile.tsx` (see other languages for examples). Note that the argument for `changeLocale` should match the property name in `resources` object in the i18n init function
* Test your language
* Create a pull request to the development branch

Expand Down
2 changes: 2 additions & 0 deletions src/calc2/components/calculator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ example, 42
<DropdownItem onClick={() => this.changeLocale('de')}>de</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('es')}>es</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('kr')}>kr</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('pt')}>pt</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('zhCn')}>zh-cn</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
<NavItem>
Expand Down
2 changes: 2 additions & 0 deletions src/calc2/components/navigation-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export class NavigationMobile extends React.Component<Props, State> {
<DropdownItem onClick={() => this.changeLocale('de')}>de</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('es')}>es</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('kr')}>kr</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('pt')}>pt</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('zhCn')}>zh-cn</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
<NavbarBrand href="/">RelaX</NavbarBrand>
Expand Down
1 change: 1 addition & 0 deletions src/calc2/components/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export class Navigation extends React.Component<Props, State> {
<DropdownItem onClick={() => this.changeLocale('es')}>es</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('kr')}>kr</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('pt')}>pt</DropdownItem>
<DropdownItem onClick={() => this.changeLocale('zhCn')}>zh-cn</DropdownItem>
</DropdownMenu>
</UncontrolledDropdown>
<NavItem className="navItemSpace"><NavLink href="https://github.com/dbis-uibk/relax/issues"><FontAwesomeIcon icon={faComment as IconProp} /> <T id="calc.navigation.feedback" /></NavLink></NavItem>
Expand Down
52 changes: 27 additions & 25 deletions src/calc2/i18n.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,37 @@ import langEN from '../locales/en.json';
import langES from '../locales/es.json';
import langKR from '../locales/kr.json';
import langPT from '../locales/pt.json';
import langZhCn from "../locales/zh-cn.json";

export type LanguageKeys = keyof typeof langEN;

export const i18n = i18next
.use(LanguageDetector)
.init({
resources: {
en: {
translations: langEN,
},
de: {
translations: langDE,
},
es: {
translations: langES,
},
kr: {
translations: langKR,
},
pt: {
translations: langPT,
},
export const i18n = i18next.use(LanguageDetector).init({
resources: {
en: {
translations: langEN,
},
fallbackLng: 'en',
nsSeparator: ':',
keySeparator: false,
defaultNS: 'translations',
debug: true,
});
de: {
translations: langDE,
},
es: {
translations: langES,
},
kr: {
translations: langKR,
},
pt: {
translations: langPT,
},
zhCn: {
translations: langZhCn,
},
},
fallbackLng: "en",
nsSeparator: ":",
keySeparator: false,
defaultNS: "translations",
debug: true,
});

export function t(key: LanguageKeys, options?: { [key: string]: string | number }): string {
return String(i18n.t(key, options));
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-cn.json

Large diffs are not rendered by default.