This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { intlShape, injectIntl, defineMessages } from 'react-intl'; | |
| const translations = defineMessages({ | |
| hello: { | |
| id: 'app.hello_world', | |
| defaultMessage: 'Hello World!', | |
| }, | |
| }); | |
| class TestComponent extends React.Component { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { intlShape, injectIntl, defineMessages } from 'react-intl'; | |
| const translations = defineMessages({ | |
| hello: { | |
| id: 'app.hello_world', | |
| defaultMessage: 'Hello World!', | |
| }, | |
| }); | |
| class TestComponent extends React.Component { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { FormattedMessage } from 'react-intl'; | |
| class TestComponent extends React.Component { | |
| render() { | |
| return( | |
| <FormattedMessage | |
| id="app.hello_world" | |
| defaultMessage="Hello World!" | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from 'react'; | |
| import ReactDOM from 'react-dom'; | |
| import { addLocaleData, IntlProvider } from 'react-intl'; | |
| import en from 'react-intl/locale-data/en'; | |
| import hu from 'react-intl/locale-data/hu'; | |
| import messagesHu from './translations/hu.json'; | |
| import messagesEn from './translations/en.json'; | |
| addLocaleData([...en, ...hu]); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { parse } from 'intl-messageformat-parser'; | |
| import * as fs from 'fs'; | |
| import { sync as globSync } from 'glob'; | |
| import { sync as mkdirpSync } from 'mkdirp'; | |
| const MESSAGES_PATTERN = './build/messages/**/*.json'; | |
| const LANG_DIR = './src/translations/temp/'; | |
| const ESCAPED_CHARS = { | |
| '\\' : '\\\\', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "build:translations": "react-intl-cra './src/**/*.js' -o ./build/messages/messages.json && babel scripts/translate.js | node", | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| import messagesEn from './src/translations/temp/en.json'; // Import the extracted tokens | |
| const messageKeys = []; | |
| const API_URL = "YOUR API URL HERE"; | |
| Object.keys(messagesEn).forEach((message) => { | |
| messageKeys.push(message); // I only send the tokens, not the default messages | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "build:translations": "react-intl-cra './src/**/*.js' -o ./build/messages/messages.json && babel scripts/translate.js | node && babel scripts/copyTranslationsToDB.js | node", | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| import * as fs from 'fs'; | |
| import { sync as mkdirpSync } from 'mkdirp'; | |
| const supportedLanguages = ['en', 'hu']; | |
| const API_URL = "YOUR API URL"; | |
| const LANG_DIR = './src/translations/'; | |
| axios.get(API_URL).then(() => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "scripts": { | |
| "build:translations": "react-intl-cra './src/**/*.js' -o ./build/messages/messages.json && babel scripts/translate.js | node && babel scripts/copyTranslationsToDB.js | node", | |
| "fetch:translations": "babel scripts/fetchTranslationsFromDB.js | node", | |
| } |
OlderNewer