mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
add german language file and integrated translation method
This commit is contained in:
parent
347517a0b3
commit
3183dae054
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
|
|
||||||
import AccordionListItemTable from './accordion_list_item_table';
|
import AccordionListItemTable from './accordion_list_item_table';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let AccordionListItem = React.createClass({
|
let AccordionListItem = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -19,7 +20,7 @@ let AccordionListItem = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div className="info-wrapper">
|
<div className="info-wrapper">
|
||||||
<h1>{this.props.content.title}</h1>
|
<h1>{this.props.content.title}</h1>
|
||||||
<h3>by {this.props.content.artist_name}</h3>
|
<h3>{getLangText('by %s', this.props.content.artist_name)}</h3>
|
||||||
</div>
|
</div>
|
||||||
<span style={{'clear': 'both'}}></span>
|
<span style={{'clear': 'both'}}></span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import Router from 'react-router';
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
let Link = Router.Link;
|
let Link = Router.Link;
|
||||||
|
|
||||||
let PaginationButton = React.createClass({
|
let PaginationButton = React.createClass({
|
||||||
@ -25,14 +27,14 @@ let PaginationButton = React.createClass({
|
|||||||
page -= 1;
|
page -= 1;
|
||||||
directionDisplay = (
|
directionDisplay = (
|
||||||
<span>
|
<span>
|
||||||
<span aria-hidden="true">←</span> Previous
|
<span aria-hidden="true">←</span> {getLangText('Previous')}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
page += 1;
|
page += 1;
|
||||||
directionDisplay = (
|
directionDisplay = (
|
||||||
<span>
|
<span>
|
||||||
Next <span aria-hidden="true">→</span>
|
{getLangText('Next')} <span aria-hidden="true">→</span>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ import NavItem from 'react-bootstrap/lib/NavItem';
|
|||||||
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
import DropdownButton from 'react-bootstrap/lib/DropdownButton';
|
||||||
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
import MenuItem from 'react-bootstrap/lib/MenuItem';
|
||||||
|
|
||||||
|
import { getLangText } from '../utils/lang_utils';
|
||||||
|
|
||||||
let Link = Router.Link;
|
let Link = Router.Link;
|
||||||
|
|
||||||
let Header = React.createClass({
|
let Header = React.createClass({
|
||||||
@ -39,12 +41,12 @@ let Header = React.createClass({
|
|||||||
</Nav>
|
</Nav>
|
||||||
<Nav right>
|
<Nav right>
|
||||||
<DropdownButton eventKey={3} title={this.state.currentUser.username}>
|
<DropdownButton eventKey={3} title={this.state.currentUser.username}>
|
||||||
<MenuItem eventKey="1" href="/art/account_settings/">Account Settings</MenuItem>
|
<MenuItem eventKey="1" href="/art/account_settings/">{getLangText('Account Settings')}</MenuItem>
|
||||||
<li className="divider"></li>
|
<li className="divider"></li>
|
||||||
<MenuItem eventKey="2" href="/art/faq/">FAQ</MenuItem>
|
<MenuItem eventKey="2" href="/art/faq/">{getLangText('FAQ')}</MenuItem>
|
||||||
<MenuItem eventKey="3" href="/art/terms/">Terms of Service</MenuItem>
|
<MenuItem eventKey="3" href="/art/terms/">{getLangText('Terms of Service')}</MenuItem>
|
||||||
<MenuItem divider />
|
<MenuItem divider />
|
||||||
<MenuItem eventKey="4" href="/api/users/logout/">Log out</MenuItem>
|
<MenuItem eventKey="4" href="/api/users/logout/">{getLangText('Log out')}</MenuItem>
|
||||||
</DropdownButton>
|
</DropdownButton>
|
||||||
</Nav>
|
</Nav>
|
||||||
</Navbar>
|
</Navbar>
|
||||||
|
@ -3,7 +3,27 @@ const languages = {
|
|||||||
'Bitcoin Address': 'Bitcoin Address',
|
'Bitcoin Address': 'Bitcoin Address',
|
||||||
'Actions': 'Actions',
|
'Actions': 'Actions',
|
||||||
'Hide all %d Editions': 'Hide all %d Editions',
|
'Hide all %d Editions': 'Hide all %d Editions',
|
||||||
'Show all %d Editions': 'Show all %d Editions'
|
'Show all %d Editions': 'Show all %d Editions',
|
||||||
|
'by %s': 'by %s',
|
||||||
|
'Account Settings': 'Account Settings',
|
||||||
|
'FAQ': 'FAQ',
|
||||||
|
'Terms of Service': 'Terms of Service',
|
||||||
|
'Log out': 'Log out',
|
||||||
|
'Previous': 'Previous',
|
||||||
|
'Next': 'Next'
|
||||||
|
},
|
||||||
|
'de': {
|
||||||
|
'Bitcoin Address': 'Bitcoin Adresse',
|
||||||
|
'Actions': 'Aktionen',
|
||||||
|
'Hide all %d Editions': 'Zeige all %d Editionen an',
|
||||||
|
'Show all %d Editions': 'Verstecke alle %d Editionen',
|
||||||
|
'by %s': 'von %s',
|
||||||
|
'Account Settings': 'Kontoeinstellungen',
|
||||||
|
'FAQ': 'Fragen & Antworten',
|
||||||
|
'Terms of Service': 'AGB',
|
||||||
|
'Log out': 'Log out',
|
||||||
|
'Previous': 'Zurück',
|
||||||
|
'Next': 'Weiter'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class Fetch {
|
|||||||
prepareUrl(url, params, attachParamsToQuery) {
|
prepareUrl(url, params, attachParamsToQuery) {
|
||||||
let newUrl = this.getUrl(url);
|
let newUrl = this.getUrl(url);
|
||||||
let re = /\${(\w+)}/g;
|
let re = /\${(\w+)}/g;
|
||||||
|
|
||||||
newUrl = newUrl.replace(re, (match, key) => {
|
newUrl = newUrl.replace(re, (match, key) => {
|
||||||
let val = params[key]
|
let val = params[key]
|
||||||
if (!val) {
|
if (!val) {
|
||||||
|
@ -4,7 +4,6 @@ import { formatText } from './general_utils';
|
|||||||
|
|
||||||
export function getLangText(s, ...args) {
|
export function getLangText(s, ...args) {
|
||||||
let lang = navigator.language || navigator.userLanguage;
|
let lang = navigator.language || navigator.userLanguage;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(lang in languages) {
|
if(lang in languages) {
|
||||||
return formatText(languages[lang][s], args);
|
return formatText(languages[lang][s], args);
|
||||||
|
Loading…
Reference in New Issue
Block a user