How to use the i18n.translate function in i18n

To help you get started, we’ve selected a few i18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ladjs / lad / template / helpers / i18n.js View on Github external
indent: '  ',
  api: {
    __: 't',
    __n: 'tn',
    __l: 'tl',
    __h: 'th',
    __mf: 'tmf'
  },
  register: i18n.api,
  defaultLocale: config.defaultLocale,
  syncFiles: config.i18nSyncFiles,
  autoReload: config.i18nAutoReload,
  updateFiles: config.i18nUpdateFiles
});

i18n.translate = function(key, locale) {
  let args = _.values(arguments).slice(2);
  if (_.isUndefined(args)) args = [];
  const phrase = config.i18n[key];
  if (!_.isString(phrase)) {
    logger.warn(`translation key missing: ${key}`);
    return;
  }
  args = [{ phrase, locale }, ...args];
  return i18n.api.t(...args);
};

i18n.middleware = function(ctx, next) {
  // expose api methods to `ctx.req` and `ctx.state`
  i18n.init(ctx.req, ctx.state);

  // override the existing locale detection with our own
github silentroach / twic3-archived / src / _chaos / popup / pages / user / components / userInfo.jsx View on Github external
<map height="{200}" width="{380}" coords="{user.coords}">
				
			);
		}

		return (
			<div id="profile">
				
				<div>
					{user.isProtected // @todo move to ul
						&amp;&amp; <i title="{i18n.translate('pages.user.protected')}">
					}
					{user.isVerified
						&amp;&amp; <i title="{i18n.translate('pages.user.verified')}">
					}
				</i></i></div><i title="{i18n.translate('pages.user.protected')}"><i title="{i18n.translate('pages.user.verified')}">

				<ul id="info">
					{name}
					{url}
					{description}
					{location}
					{map}
				</ul>
			</i></i></div><i title="{i18n.translate('pages.user.protected')}"><i title="{i18n.translate('pages.user.verified')}">
		);</i></i></map>
github silentroach / twic3-archived / src / _chaos / popup / pages / accounts / components / accountAdd.jsx View on Github external
render() {
		var title = this.state.disabled
			? i18n.translate('pages.accounts.errors.connection')
			: i18n.translate('pages.accounts.add');

		return (
			<a title="{title}">
				{i18n.translate('pages.accounts.add')}
			</a>
		);
	}
}
github silentroach / twic3-archived / src / _chaos / popup / pages / user / components / userNotFound.jsx View on Github external
render() {
		return (
			<div id="profile-none">{i18n.translate('pages.user.not_found')}</div>
		);
	}
}
github silentroach / twic3-archived / src / _chaos / background / app.js View on Github external
updateToolbar() {
		const imagePrefix = 'images/toolbar' + (connection.connected ? '' : '.disconnected');
		const nameParts = [chrome.runtime.getManifest().name];

		if (!connection.connected) {
			nameParts.push(i18n.translate('toolbar.disconnected'));
		}

		chrome.browserAction.setIcon({
			path: {
				19: [imagePrefix, '.png'].join(''),
				38: [imagePrefix, '@2x', '.png'].join('')
			}
		});

		chrome.browserAction.setTitle({
			title: nameParts.join(' - ')
		});
	}
github silentroach / twic3-archived / src / chrome / popup / index.jsx View on Github external
render() {
		const Page = this.state &amp;&amp; this.state.page ? this.state.page : null;

		return (
			
				<div>
					
						
						
					

					{Page
						? 
						: ''
					}
				</div>
			
		);
	}
github silentroach / twic3-archived / src / _chaos / popup / pages / accounts / components / account.jsx View on Github external
render() {
		const user = this.props.user;
		const url = ['#timeline', user.id].join('/');
		const classes = ['account'];
		let title;

		if (this.props.modifierPressed) {
			classes.push('account-remove-candidate');
		}

		if (!user.isAuthorized) {
			classes.push('account-need-auth');
			title = i18n.translate('pages.accounts.authenticate');
		}

		return (
			<li>
				<a title="{title}" href="{url}">
					
					<span>+</span>
					<span>
						{user.screenName ? user.screenName : user.name}
					</span>
				</a>
			</li>
		);
	}
github silentroach / twic3-archived / src / _chaos / popup / pages / accounts / index.jsx View on Github external
render() {
		var hintTranslation;

		if (!this.state.modifierKeyPressed) {
			hintTranslation = i18n.translate('pages.accounts.hint.' + HINT_KEY);
		} else {
			hintTranslation = i18n.translate('pages.accounts.remove_hint');
		}

		return (
			<div>
				
				
					{hintTranslation}
				
			</div>
		);
	}
github silentroach / twic3-archived / src / _chaos / popup / pages / user / index.jsx View on Github external
render() {
		if (this.state.loading) {
			return ;
		} else
		if (!this.state.data) {
			return ;
		} else {
			return ;
		}
	}
github silentroach / twic3-archived / src / _chaos / popup / pages / accounts / components / accountAdd.jsx View on Github external
render() {
		var title = this.state.disabled
			? i18n.translate('pages.accounts.errors.connection')
			: i18n.translate('pages.accounts.add');

		return (
			<a title="{title}">
				{i18n.translate('pages.accounts.add')}
			</a>
		);
	}
}