Skip to content

Commit 7ce2c26

Browse files
i18n support
1 parent 46768b3 commit 7ce2c26

38 files changed

+7820
-5168
lines changed

.babelrc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
{
2-
"presets": ["flow", "react-native"],
2+
"presets": ["@babel/preset-env", "@babel/preset-react", "@babel/flow"],
3+
"plugins": [
4+
"@babel/plugin-proposal-class-properties",
5+
"@babel/plugin-transform-runtime",
6+
"@babel/plugin-proposal-object-rest-spread"
7+
],
38
"env": {
4-
"development": {
5-
"plugins": [
6-
"transform-react-jsx-source",
7-
"transform-inline-environment-variables"
9+
"production": {
10+
"presets": [
11+
[
12+
"@babel/env",
13+
{
14+
"modules": false
15+
}
16+
]
817
]
918
}
1019
}

.eslintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"arrow-body-style": 2,
2525
"require-await": 2,
2626
"react/prop-types": 0,
27+
"no-class-assign": 0,
2728
"no-var": 2,
2829
"linebreak-style": [2, "unix"],
2930
"semi": [1, "always"],

README.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,7 @@ You can find your `API_KEY` and `APP_ID` on Stream's dashboard.
124124
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.
125125

126126
```js
127-
const client = stream.connect(
128-
API_KEY,
129-
API_SECRET,
130-
);
127+
const client = stream.connect(API_KEY, API_SECRET);
131128
const userToken = client.createUserToken(userId);
132129
console.log(userToken);
133130
```
@@ -137,10 +134,7 @@ console.log(userToken);
137134
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.
138135

139136
```js
140-
const client = stream.connect(
141-
API_KEY,
142-
API_SECRET,
143-
);
137+
const client = stream.connect(API_KEY, API_SECRET);
144138
const analyticsToken = client.getAnalyticsToken();
145139
console.log(analyticsToken);
146140
```

babel.i18next-extract.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": [
4+
[
5+
"i18next-extract",
6+
{
7+
"contextSeparator": "__",
8+
"defaultContexts": [""],
9+
"defaultNS": "en",
10+
"locales": ["nl", "en", "it", "tr", "fr", "hi", "ru"],
11+
"jsonSpace": 4,
12+
"keySeparator": null,
13+
"nsSeparator": null,
14+
"keyAsDefaultValue": ["en"],
15+
"keyAsDefaultValueForDerivedKeys": false,
16+
"outputPath": "src/i18n/{{locale}}.json",
17+
"discardOldKeys": true
18+
}
19+
],
20+
"@babel/proposal-class-properties",
21+
"@babel/transform-runtime"
22+
]
23+
}

bin/validate-translations.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* eslint-disable no-undef */
2+
3+
const path = require('path');
4+
const fs = require('fs');
5+
const i18nDirectoryRelativePath = '../src/i18n/';
6+
const directoryPath = path.join(__dirname, i18nDirectoryRelativePath);
7+
let countMissingTranslations = 0;
8+
9+
fs.readdir(directoryPath, function(err, files) {
10+
if (err) {
11+
return console.log('Unable to scan directory: ' + err);
12+
}
13+
14+
files.forEach(function(file) {
15+
if (file === 'index.js') return;
16+
// Do whatever you want to do with the file
17+
const data = require(i18nDirectoryRelativePath + file);
18+
const keys = Object.keys(data);
19+
keys.forEach((key) => {
20+
if (!data[key] || data[key] === '') {
21+
countMissingTranslations = countMissingTranslations + 1;
22+
console.error(
23+
'\\033[91m',
24+
'Missing translation for key "' + key + '" in "' + file + '"',
25+
);
26+
}
27+
});
28+
});
29+
30+
if (countMissingTranslations > 0) {
31+
process.exitCode = 2;
32+
process.exit();
33+
} else {
34+
process.exit(0);
35+
}
36+
});

native-package/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,20 @@
1313
"notification feed"
1414
],
1515
"devDependencies": {
16-
"babel-cli": "^6.26.0",
16+
"@babel/cli": "^7.1.0",
17+
"@babel/core": "^7.0.0",
18+
"@babel/node": "^7.0.0",
19+
"@babel/plugin-external-helpers": "^7.0.0",
20+
"@babel/plugin-proposal-class-properties": "^7.1.0",
21+
"@babel/plugin-transform-runtime": "^7.2.0",
22+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
23+
"@babel/preset-env": "^7.0.0",
24+
"@babel/preset-flow": "^7.0.0",
25+
"@babel/preset-react": "^7.0.0",
26+
"@babel/runtime-corejs2": "^7.2.0",
1727
"babel-eslint": "^8.2.5",
1828
"babel-plugin-root-import": "^6.1.0",
1929
"babel-plugin-transform-inline-environment-variables": "^0.4.3",
20-
"babel-preset-env": "^1.7.0",
21-
"babel-preset-flow": "^6.23.0",
2230
"eslint": "^5.1.0",
2331
"eslint-plugin-flowtype": "^2.29.1",
2432
"eslint-plugin-jest": "^21.17.0",

0 commit comments

Comments
 (0)