Skip to content

Commit

Permalink
i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Mar 30, 2020
1 parent 46768b3 commit 7ce2c26
Show file tree
Hide file tree
Showing 38 changed files with 7,820 additions and 5,168 deletions.
19 changes: 14 additions & 5 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
{
"presets": ["flow", "react-native"],
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/flow"],
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-transform-runtime",
"@babel/plugin-proposal-object-rest-spread"
],
"env": {
"development": {
"plugins": [
"transform-react-jsx-source",
"transform-inline-environment-variables"
"production": {
"presets": [
[
"@babel/env",
{
"modules": false
}
]
]
}
}
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"arrow-body-style": 2,
"require-await": 2,
"react/prop-types": 0,
"no-class-assign": 0,
"no-var": 2,
"linebreak-style": [2, "unix"],
"semi": [1, "always"],
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,7 @@ You can find your `API_KEY` and `APP_ID` on Stream's dashboard.
The authentication user token cannot be generated client-side (that would require sharing your API secret). You should provision a user token as part of the sign-up / login flow to your application from your backend.

```js
const client = stream.connect(
API_KEY,
API_SECRET,
);
const client = stream.connect(API_KEY, API_SECRET);
const userToken = client.createUserToken(userId);
console.log(userToken);
```
Expand All @@ -137,10 +134,7 @@ console.log(userToken);
React components have analytics instrumentation built-in, this simplifies the integration with Stream. In order to enable analytics tracking, you need to initialize `StreamApp` with a valid analytics token. You can generate this server-side as well.

```js
const client = stream.connect(
API_KEY,
API_SECRET,
);
const client = stream.connect(API_KEY, API_SECRET);
const analyticsToken = client.getAnalyticsToken();
console.log(analyticsToken);
```
Expand Down
23 changes: 23 additions & 0 deletions babel.i18next-extract.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"i18next-extract",
{
"contextSeparator": "__",
"defaultContexts": [""],
"defaultNS": "en",
"locales": ["nl", "en", "it", "tr", "fr", "hi", "ru"],
"jsonSpace": 4,
"keySeparator": null,
"nsSeparator": null,
"keyAsDefaultValue": ["en"],
"keyAsDefaultValueForDerivedKeys": false,
"outputPath": "src/i18n/{{locale}}.json",
"discardOldKeys": true
}
],
"@babel/proposal-class-properties",
"@babel/transform-runtime"
]
}
36 changes: 36 additions & 0 deletions bin/validate-translations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* eslint-disable no-undef */

const path = require('path');
const fs = require('fs');
const i18nDirectoryRelativePath = '../src/i18n/';
const directoryPath = path.join(__dirname, i18nDirectoryRelativePath);
let countMissingTranslations = 0;

fs.readdir(directoryPath, function(err, files) {
if (err) {
return console.log('Unable to scan directory: ' + err);
}

files.forEach(function(file) {
if (file === 'index.js') return;
// Do whatever you want to do with the file
const data = require(i18nDirectoryRelativePath + file);
const keys = Object.keys(data);
keys.forEach((key) => {
if (!data[key] || data[key] === '') {
countMissingTranslations = countMissingTranslations + 1;
console.error(
'\\033[91m',
'Missing translation for key "' + key + '" in "' + file + '"',
);
}
});
});

if (countMissingTranslations > 0) {
process.exitCode = 2;
process.exit();
} else {
process.exit(0);
}
});
14 changes: 11 additions & 3 deletions native-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@
"notification feed"
],
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.1.0",
"@babel/core": "^7.0.0",
"@babel/node": "^7.0.0",
"@babel/plugin-external-helpers": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-transform-runtime": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime-corejs2": "^7.2.0",
"babel-eslint": "^8.2.5",
"babel-plugin-root-import": "^6.1.0",
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
"babel-preset-env": "^1.7.0",
"babel-preset-flow": "^6.23.0",
"eslint": "^5.1.0",
"eslint-plugin-flowtype": "^2.29.1",
"eslint-plugin-jest": "^21.17.0",
Expand Down
Loading

0 comments on commit 7ce2c26

Please sign in to comment.