Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
// with only callback
i18next.init((err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err)
return
}
t('key') // -> same as i18next.t
})
const v: string = i18next.t('my.key')
const a: boolean = i18next.exists('my.key')
// fix language to german
const de = i18next.getFixedT('de')
const z: string = de('myKey')
// or fix the namespace to anotherNamespace
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace')
const x: string = anotherNamespace('anotherNamespaceKey') // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');
i18next.changeLanguage('en', (err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err)
return
}
t('key') // -> same as i18next.t
})
i18next.loadNamespaces('myNamespace', (err: any, t: i18next.TranslationFunction) => {
/* resources have been loaded */
if (err) {
console.log('something went wrong loading', err)
return
}
t('key') // -> same as i18next.t
})
const v: string = i18next.t('my.key')
const a: boolean = i18next.exists('my.key')
// fix language to german
const de = i18next.getFixedT('de')
const z: string = de('myKey')
// or fix the namespace to anotherNamespace
const anotherNamespace = i18next.getFixedT(null, 'anotherNamespace')
const x: string = anotherNamespace('anotherNamespaceKey') // no need to prefix ns i18n.t('anotherNamespace:anotherNamespaceKey');
i18next.changeLanguage('en', (err: any, t: i18next.TranslationFunction) => {
if (err) {
console.log('something went wrong loading', err)
return
}
t('key') // -> same as i18next.t
})
i18next.loadNamespaces('myNamespace', (err: any, t: i18next.TranslationFunction) => {
/* resources have been loaded */
})
i18next.loadNamespaces(
['myNamespace1', 'myNamespace2'],
(err: any, t: i18next.TranslationFunction) => {
// Reset internal states
this.wait(true);
this.isError(false);
const targetLanguage: string = this.selectedLanguage();
const peerWebAbsoluteUrl = _spPageContextInfo.siteAbsoluteUrl + "/" + targetLanguage.toLowerCase();
const peerWebServerRelativeUrl = _spPageContextInfo.siteServerRelativeUrl + "/" + targetLanguage.toLowerCase();
const peerWeb = new Web(peerWebAbsoluteUrl);
const currentWeb = new Web(_spPageContextInfo.webAbsoluteUrl);
// Build the destination file URL
// Get the Pages library name in the target language
const i18nTargetLanguage = i18n.getFixedT(targetLanguage.toLowerCase());
const pagesLibraryName = i18nTargetLanguage("pagesLibraryName");
const regex = "\/" + pagesLibraryName + "\/(.*)\/.*\.aspx";
const regexInstance = new RegExp(regex, "g");
const currentPageFolder = regexInstance.exec(this.currentPageUrl);
const folderName = currentPageFolder ? ("/" + currentPageFolder[1] + "/") : "/";
const fileName = this.inputDestinationFileName() + ".aspx";
const destinationFilePath = peerWebServerRelativeUrl + "/" + pagesLibraryName + folderName + fileName;
const web = new Web(_spPageContextInfo.webAbsoluteUrl);
this.ensurePageGuid().then(() => {
// Copy the page in the Pages library of the peer web with the new language
// Note: during the copy operation, all original metadata are retained by default
export function getTranslatorForAddress(address: string) {
const registration = registrations[address]
const language = registration && registration.language
// Language is set and i18next has the proper config
if (language) {
console.info(`Language resolved as ${language} for user address ${address}`)
return i18next.getFixedT(language)
}
// If language is not supported falls back to env.DEFAULT_LOCALE
console.info(`Users ${address} language is not set, valid or supported`)
return i18next.t.bind(i18next)
}
beforeEach(() => {
const app = new VoxaApp({ views });
const skill = new AlexaPlatform(app);
renderer = new Renderer({ views, variables });
event = new AlexaEvent(rb.getIntentRequest("SomeIntent"));
event.renderer = renderer;
event.t = i18n.getFixedT(event.request.locale);
event.platform = skill;
reply = new AlexaReply();
});
beforeEach(() => {
voxaApp = new VoxaApp({ views });
renderer = new Renderer({ views, variables });
rawEvent = rb.getIntentRequest("SomeIntent");
event = new AlexaEvent(rawEvent);
event.platform = new AlexaPlatform(voxaApp);
event.t = i18n.getFixedT("en-US");
statesDefinition = {
LaunchIntent: { to: "endState" },
SomeIntent: { to: "endState" },
endState: { ask: "ExitIntent.Farewell", to: "die" },
initState: { to: "endState" },
secondState: { to: "initState" },
thirdState: () => Promise.resolve({ to: "endState" }),
};
});
.add('SearchBox', () => {
const [text, setText] = useState('text')
return (
{
setText(text)
action('Input')(text)
}}
onSearch={text => {
setText(text)
action('Search')(text)
}}
onHeightChanged={action('Height Changed')}
/>
)
})
getT (ns) {
return i18next.getFixedT(this.lng, ns || this.ns)
}
}
{ Object.keys(locales).map(locale => (
<option value="{">{ i18n.getFixedT(locale)('/displayName') }</option>
)) }
.add('Profiles', () => {
const profiles = Array.from(Array(5)).map((_, i) => ({
id: `profile${i + 1}`,
name: `Profile${i + 1}`
}))
const profilesOption = profiles.reduce((o, p) => {
o[p.name] = p.id
return o
}, {})
return (
)
})