Files
jitsi-meet/react/features/base/i18n/functions.js
Дамян Минков ea4d49f2a0 Adds new format of phoneList service and re-design dial in numbers page. (#3903)
* Adds new format of phoneList service and re-design dial in numbers page.

Adds flags and country names (with translations) for the numbers if using the new format.

* Fixes tests and fixes get default number.

* Updates swagger with new format.

* Moves html back yo table.

Fixes displaying on mobile and also the tel: URI generation. The tel: URI is tested on Android and iOS and seems to work (Android was not interpreting 'p', but both seems to like ',').

* Fixes a wrong return statement.

* Small fixes.
2019-02-26 13:32:46 +00:00

34 lines
1.2 KiB
JavaScript

import React from 'react';
import { translate as reactI18nextTranslate } from 'react-i18next';
/**
* Wraps a specific React Component in order to enable translations in it.
*
* @param {Component} component - The React Component to wrap.
* @param {Object} options - Additional options to pass into react-i18next's
* initialization.
* @returns {Component} The React Component which wraps {@link component} and
* enables translations in it.
*/
export function translate(component, options = { wait: true }) {
// Use the default list of namespaces.
return (
reactI18nextTranslate([ 'main', 'languages', 'countries' ], options)(
component));
}
/**
* Translates a specific key to text containing HTML via a specific translate
* function.
*
* @param {Function} t - The translate function.
* @param {string} key - The key to translate.
* @param {Array<*>} options - The options, if any, to pass to {@link t}.
* @returns {ReactElement} A ReactElement which depicts the translated HTML
* text.
*/
export function translateToHTML(t, key, options = {}) {
// eslint-disable-next-line react/no-danger
return <span dangerouslySetInnerHTML = {{ __html: t(key, options) }} />;
}