dep updates (fe)

pull/1552/head
gabrielburnworth 2019-10-30 13:14:31 -07:00
parent 011e900aee
commit c7d44453aa
7 changed files with 38 additions and 27 deletions

View File

@ -1,7 +1,7 @@
import { detectLanguage } from "../i18n"; import { detectLanguage } from "../i18n";
import { attachToRoot } from "../util"; import { attachToRoot } from "../util";
import { stopIE } from "../util/stop_ie"; import { stopIE } from "../util/stop_ie";
import I from "i18next"; import I, { InitOptions } from "i18next";
import { DemoIframe } from "./demo_iframe"; import { DemoIframe } from "./demo_iframe";
// ENTRY POINT FOR WEB APP DEMO IFRAME =========== // ENTRY POINT FOR WEB APP DEMO IFRAME ===========
@ -10,6 +10,6 @@ stopIE();
const doAttach = () => attachToRoot(DemoIframe); const doAttach = () => attachToRoot(DemoIframe);
const loadDemo = const loadDemo =
(config: I.InitOptions) => I.init(config, doAttach); (config: InitOptions) => I.init(config, doAttach);
detectLanguage().then(loadDemo); detectLanguage().then(loadDemo);

2
frontend/hacks.d.ts vendored
View File

@ -19,7 +19,7 @@ interface Window {
} }
declare namespace jest { declare namespace jest {
export interface Matchers<R> { export interface Matchers<R, T> {
toBeSameTimeAs: jest.Expect; toBeSameTimeAs: jest.Expect;
} }
} }

View File

@ -1,5 +1,5 @@
import axios from "axios"; import axios from "axios";
import I from "i18next"; import { InitOptions } from "i18next";
import { merge } from "lodash"; import { merge } from "lodash";
const translationFilePath = (lang: string): string => const translationFilePath = (lang: string): string =>
@ -26,7 +26,7 @@ type Translations = { [key: string]: string };
const parseTranslationData = (data: TranslationFile): Translations => const parseTranslationData = (data: TranslationFile): Translations =>
merge(data["translated"], data["untranslated"], data["other_translations"]); merge(data["translated"], data["untranslated"], data["other_translations"]);
export function generateI18nConfig(lang: string): Promise<I.InitOptions> { export function generateI18nConfig(lang: string): Promise<InitOptions> {
return axios return axios
.get<TranslationFile>(translationFilePath(lang)) .get<TranslationFile>(translationFilePath(lang))
.then(response => { .then(response => {

View File

@ -1,4 +1,4 @@
import I from "i18next"; import { Callback } from "i18next";
import _React, { createElement } from "react"; import _React, { createElement } from "react";
import { render } from "react-dom"; import { render } from "react-dom";
import { PasswordReset } from "./password_reset"; import { PasswordReset } from "./password_reset";
@ -6,7 +6,7 @@ import { bail } from "../util";
export const MISSING_DIV = "Add a div with id `root` to the page first."; export const MISSING_DIV = "Add a div with id `root` to the page first.";
export const onInit: I.Callback = async () => { export const onInit: Callback = async () => {
const node = document.createElement("DIV"); const node = document.createElement("DIV");
node.id = "root"; node.id = "root";
document.body.appendChild(node); document.body.appendChild(node);

View File

@ -29,15 +29,15 @@
"@blueprintjs/datetime": "3.14.0", "@blueprintjs/datetime": "3.14.0",
"@blueprintjs/select": "3.11.1", "@blueprintjs/select": "3.11.1",
"@types/enzyme": "3.10.3", "@types/enzyme": "3.10.3",
"@types/jest": "24.0.19", "@types/jest": "24.0.21",
"@types/lodash": "4.14.144", "@types/lodash": "4.14.144",
"@types/markdown-it": "0.0.9", "@types/markdown-it": "0.0.9",
"@types/moxios": "0.4.9", "@types/moxios": "0.4.9",
"@types/node": "12.11.5", "@types/node": "12.12.3",
"@types/promise-timeout": "1.3.0", "@types/promise-timeout": "1.3.0",
"@types/react": "16.9.9", "@types/react": "16.9.11",
"@types/react-color": "3.0.1", "@types/react-color": "3.0.1",
"@types/react-dom": "16.9.2", "@types/react-dom": "16.9.3",
"@types/react-redux": "7.1.5", "@types/react-redux": "7.1.5",
"axios": "0.19.0", "axios": "0.19.0",
"boxed_value": "1.0.0", "boxed_value": "1.0.0",
@ -46,7 +46,7 @@
"enzyme": "3.10.0", "enzyme": "3.10.0",
"enzyme-adapter-react-16": "1.15.1", "enzyme-adapter-react-16": "1.15.1",
"farmbot": "8.3.0-rc6", "farmbot": "8.3.0-rc6",
"i18next": "17.3.0", "i18next": "19.0.0",
"install": "0.13.0", "install": "0.13.0",
"lodash": "4.17.15", "lodash": "4.17.15",
"markdown-it": "10.0.0", "markdown-it": "10.0.0",
@ -54,7 +54,7 @@
"moment": "2.24.0", "moment": "2.24.0",
"moxios": "0.4.0", "moxios": "0.4.0",
"mqtt": "3.0.0", "mqtt": "3.0.0",
"npm": "6.12.0", "npm": "6.12.1",
"parcel-bundler": "1.12.4", "parcel-bundler": "1.12.4",
"promise-timeout": "1.3.0", "promise-timeout": "1.3.0",
"raf": "3.4.1", "raf": "3.4.1",
@ -83,7 +83,7 @@
"jest-cli": "24.9.0", "jest-cli": "24.9.0",
"jest-skipped-reporter": "0.0.4", "jest-skipped-reporter": "0.0.4",
"jshint": "2.10.2", "jshint": "2.10.2",
"madge": "3.4.4" "madge": "3.5.0"
}, },
"jest": { "jest": {
"clearMocks": true, "clearMocks": true,

View File

@ -96,13 +96,25 @@ var HelperNamespace = (function () {
console.dir(getAllTags()); console.dir(getAllTags());
} }
/** For debugging. Replace all characters except whitespace and {{ words }} */
function repl(string, character) {
var parts = string.split("{{");
if (parts.length < 2) { return string.replace(/\S/g, character); }
var insideAndAfter = parts[1].split("}}");
var before = parts[0].replace(/\S/g, character);
var inside = insideAndAfter[0];
var after = insideAndAfter[1].replace(/\S/g, character);
var firstPart = [before, inside].join("{{");
return [firstPart, after].join("}}");
}
/** For debugging. Replace all translations with a debug string. */ /** For debugging. Replace all translations with a debug string. */
function replaceWithDebugString(key, debugString, debugStringOption) { function replaceWithDebugString(key, debugString, debugStringOption) {
var debugChar = debugString[0]; var debugChar = debugString[0];
switch (debugStringOption) { switch (debugStringOption) {
case 'r': return debugString; // replace with: string as provided case 'r': return debugString; // replace with: string as provided
case 's': return debugChar; // single character case 's': return debugChar; // single character
case 'n': return key.replace(/\S/g, debugChar); // maintain whitespace case 'n': return repl(key, debugChar); // maintain whitespace
case 'l': return debugChar.repeat(key.length); // replace whitespace case 'l': return debugChar.repeat(key.length); // replace whitespace
default: return key; default: return key;
} }

View File

@ -18,21 +18,20 @@ npm run translation-check
See the [README](https://github.com/FarmBot/Farmbot-Web-App#translating-the-web-app-into-your-language) for contribution instructions. See the [README](https://github.com/FarmBot/Farmbot-Web-App#translating-the-web-app-into-your-language) for contribution instructions.
Total number of phrases identified by the language helper for translation: __1101__ Total number of phrases identified by the language helper for translation: __1114__
|Language|Percent translated|Translated|Untranslated|Other Translations| |Language|Percent translated|Translated|Untranslated|Other Translations|
|:---:|---:|---:|---:|---:| |:---:|---:|---:|---:|---:|
|af|100%|1101|0|1| |da|10%|110|1004|34|
|da|10%|110|991|31| |de|38%|418|696|131|
|de|38%|420|681|128| |es|91%|1012|102|163|
|es|92%|1015|86|160| |fr|68%|759|355|188|
|fr|69%|762|339|186| |it|8%|90|1024|180|
|it|8%|89|1012|178| |nl|7%|79|1035|151|
|nl|7%|79|1022|148| |pt|6%|71|1043|170|
|pt|6%|71|1030|167| |ru|54%|601|513|211|
|ru|55%|604|497|208| |th|0%|0|1114|0|
|th|0%|0|1101|0| |zh|8%|86|1028|151|
|zh|8%|86|1015|148|
**Percent translated** refers to the percent of phrases identified by the **Percent translated** refers to the percent of phrases identified by the
language helper that have been translated. Additional phrases not identified language helper that have been translated. Additional phrases not identified