From c7d44453aa0393c20d78d6b0ba80f8f02384b4ee Mon Sep 17 00:00:00 2001 From: gabrielburnworth Date: Wed, 30 Oct 2019 13:14:31 -0700 Subject: [PATCH] dep updates (fe) --- frontend/demo/index.tsx | 4 ++-- frontend/hacks.d.ts | 2 +- frontend/i18n.ts | 4 ++-- frontend/password_reset/on_init.ts | 4 ++-- package.json | 14 +++++------ public/app-resources/languages/_helper.js | 14 ++++++++++- .../languages/translation_metrics.md | 23 +++++++++---------- 7 files changed, 38 insertions(+), 27 deletions(-) diff --git a/frontend/demo/index.tsx b/frontend/demo/index.tsx index 03e0e2157..2a191620f 100644 --- a/frontend/demo/index.tsx +++ b/frontend/demo/index.tsx @@ -1,7 +1,7 @@ import { detectLanguage } from "../i18n"; import { attachToRoot } from "../util"; import { stopIE } from "../util/stop_ie"; -import I from "i18next"; +import I, { InitOptions } from "i18next"; import { DemoIframe } from "./demo_iframe"; // ENTRY POINT FOR WEB APP DEMO IFRAME =========== @@ -10,6 +10,6 @@ stopIE(); const doAttach = () => attachToRoot(DemoIframe); const loadDemo = - (config: I.InitOptions) => I.init(config, doAttach); + (config: InitOptions) => I.init(config, doAttach); detectLanguage().then(loadDemo); diff --git a/frontend/hacks.d.ts b/frontend/hacks.d.ts index c226cd127..70f71bc17 100644 --- a/frontend/hacks.d.ts +++ b/frontend/hacks.d.ts @@ -19,7 +19,7 @@ interface Window { } declare namespace jest { - export interface Matchers { + export interface Matchers { toBeSameTimeAs: jest.Expect; } } diff --git a/frontend/i18n.ts b/frontend/i18n.ts index a9bd3dc7e..690a9375d 100644 --- a/frontend/i18n.ts +++ b/frontend/i18n.ts @@ -1,5 +1,5 @@ import axios from "axios"; -import I from "i18next"; +import { InitOptions } from "i18next"; import { merge } from "lodash"; const translationFilePath = (lang: string): string => @@ -26,7 +26,7 @@ type Translations = { [key: string]: string }; const parseTranslationData = (data: TranslationFile): Translations => merge(data["translated"], data["untranslated"], data["other_translations"]); -export function generateI18nConfig(lang: string): Promise { +export function generateI18nConfig(lang: string): Promise { return axios .get(translationFilePath(lang)) .then(response => { diff --git a/frontend/password_reset/on_init.ts b/frontend/password_reset/on_init.ts index 20cfb69e7..b4231f092 100644 --- a/frontend/password_reset/on_init.ts +++ b/frontend/password_reset/on_init.ts @@ -1,4 +1,4 @@ -import I from "i18next"; +import { Callback } from "i18next"; import _React, { createElement } from "react"; import { render } from "react-dom"; 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 onInit: I.Callback = async () => { +export const onInit: Callback = async () => { const node = document.createElement("DIV"); node.id = "root"; document.body.appendChild(node); diff --git a/package.json b/package.json index f65fb1fdd..1bb9eec62 100644 --- a/package.json +++ b/package.json @@ -29,15 +29,15 @@ "@blueprintjs/datetime": "3.14.0", "@blueprintjs/select": "3.11.1", "@types/enzyme": "3.10.3", - "@types/jest": "24.0.19", + "@types/jest": "24.0.21", "@types/lodash": "4.14.144", "@types/markdown-it": "0.0.9", "@types/moxios": "0.4.9", - "@types/node": "12.11.5", + "@types/node": "12.12.3", "@types/promise-timeout": "1.3.0", - "@types/react": "16.9.9", + "@types/react": "16.9.11", "@types/react-color": "3.0.1", - "@types/react-dom": "16.9.2", + "@types/react-dom": "16.9.3", "@types/react-redux": "7.1.5", "axios": "0.19.0", "boxed_value": "1.0.0", @@ -46,7 +46,7 @@ "enzyme": "3.10.0", "enzyme-adapter-react-16": "1.15.1", "farmbot": "8.3.0-rc6", - "i18next": "17.3.0", + "i18next": "19.0.0", "install": "0.13.0", "lodash": "4.17.15", "markdown-it": "10.0.0", @@ -54,7 +54,7 @@ "moment": "2.24.0", "moxios": "0.4.0", "mqtt": "3.0.0", - "npm": "6.12.0", + "npm": "6.12.1", "parcel-bundler": "1.12.4", "promise-timeout": "1.3.0", "raf": "3.4.1", @@ -83,7 +83,7 @@ "jest-cli": "24.9.0", "jest-skipped-reporter": "0.0.4", "jshint": "2.10.2", - "madge": "3.4.4" + "madge": "3.5.0" }, "jest": { "clearMocks": true, diff --git a/public/app-resources/languages/_helper.js b/public/app-resources/languages/_helper.js index 9ac938f00..459fa44a9 100644 --- a/public/app-resources/languages/_helper.js +++ b/public/app-resources/languages/_helper.js @@ -96,13 +96,25 @@ var HelperNamespace = (function () { 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. */ function replaceWithDebugString(key, debugString, debugStringOption) { var debugChar = debugString[0]; switch (debugStringOption) { case 'r': return debugString; // replace with: string as provided 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 default: return key; } diff --git a/public/app-resources/languages/translation_metrics.md b/public/app-resources/languages/translation_metrics.md index 07e6a6bd8..f31f23062 100644 --- a/public/app-resources/languages/translation_metrics.md +++ b/public/app-resources/languages/translation_metrics.md @@ -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. -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| |:---:|---:|---:|---:|---:| -|af|100%|1101|0|1| -|da|10%|110|991|31| -|de|38%|420|681|128| -|es|92%|1015|86|160| -|fr|69%|762|339|186| -|it|8%|89|1012|178| -|nl|7%|79|1022|148| -|pt|6%|71|1030|167| -|ru|55%|604|497|208| -|th|0%|0|1101|0| -|zh|8%|86|1015|148| +|da|10%|110|1004|34| +|de|38%|418|696|131| +|es|91%|1012|102|163| +|fr|68%|759|355|188| +|it|8%|90|1024|180| +|nl|7%|79|1035|151| +|pt|6%|71|1043|170| +|ru|54%|601|513|211| +|th|0%|0|1114|0| +|zh|8%|86|1028|151| **Percent translated** refers to the percent of phrases identified by the language helper that have been translated. Additional phrases not identified