From e0e2d98cd08fa04eb410f3f9deaf9f5a85460a86 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Fri, 12 Jun 2020 23:55:23 -0500 Subject: [PATCH] rename translation files This fixes case-insensitive file name conflicts, e.g. editor.ts Editor.ts --- src/components/ActionButton.tsx | 4 ++-- src/components/BluetoothButton.tsx | 2 +- src/components/DocsButton.tsx | 2 +- src/components/Editor.tsx | 4 ++-- src/components/FlashButton.tsx | 2 +- src/components/LinkButton.tsx | 4 ++-- src/components/Notification.tsx | 5 +++-- src/components/OpenButton.tsx | 2 +- src/components/OpenFileButton.tsx | 4 ++-- src/components/ReplButton.tsx | 2 +- src/components/RunButton.tsx | 2 +- src/components/SaveAsButton.tsx | 2 +- src/components/StopButton.tsx | 2 +- src/components/SupportButton.tsx | 2 +- src/components/Terminal.tsx | 4 ++-- .../{button.en.json => button-i18n.en.json} | 0 .../{button.test.ts => button-i18n.test.ts} | 4 ++-- src/components/{button.ts => button-i18n.ts} | 2 ++ .../{editor.en.json => editor-i18n.en.json} | 0 .../{editor.test.ts => editor-i18n.test.ts} | 4 ++-- src/components/{editor.ts => editor-i18n.ts} | 2 ++ ...ication.en.json => notification-i18n.en.json} | 0 ...ication.test.ts => notification-i18n.test.ts} | 4 ++-- src/components/notification-i18n.ts | 16 ++++++++++++++++ .../{terminal.en.json => terminal-i18n.en.json} | 0 .../{terminal.test.ts => terminal-i18n.test.ts} | 4 ++-- src/components/{terminal.ts => terminal-i18n.ts} | 2 ++ src/reducers/notification.ts | 13 +------------ 28 files changed, 53 insertions(+), 41 deletions(-) rename src/components/{button.en.json => button-i18n.en.json} (100%) rename src/components/{button.test.ts => button-i18n.test.ts} (77%) rename src/components/{button.ts => button-i18n.ts} (87%) rename src/components/{editor.en.json => editor-i18n.en.json} (100%) rename src/components/{editor.test.ts => editor-i18n.test.ts} (77%) rename src/components/{editor.ts => editor-i18n.ts} (80%) rename src/components/{notification.en.json => notification-i18n.en.json} (100%) rename src/components/{notification.test.ts => notification-i18n.test.ts} (75%) create mode 100644 src/components/notification-i18n.ts rename src/components/{terminal.en.json => terminal-i18n.en.json} (100%) rename src/components/{terminal.test.ts => terminal-i18n.test.ts} (76%) rename src/components/{terminal.ts => terminal-i18n.ts} (71%) diff --git a/src/components/ActionButton.tsx b/src/components/ActionButton.tsx index 17403594..050b3bf4 100644 --- a/src/components/ActionButton.tsx +++ b/src/components/ActionButton.tsx @@ -4,8 +4,8 @@ import { Button, Intent, Position, Tooltip } from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; -import { TooltipId } from './button'; -import en from './button.en.json'; +import { TooltipId } from './button-i18n'; +import en from './button-i18n.en.json'; export interface ActionButtonProps { /** A unique id for each instance. */ diff --git a/src/components/BluetoothButton.tsx b/src/components/BluetoothButton.tsx index 33702631..bd455814 100644 --- a/src/components/BluetoothButton.tsx +++ b/src/components/BluetoothButton.tsx @@ -8,7 +8,7 @@ import { RootState } from '../reducers'; import { BleConnectionState } from '../reducers/ble'; import { BootloaderConnectionState } from '../reducers/bootloader'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import btConnectedIcon from './images/bt-connected.svg'; import btDisconnectedIcon from './images/bt-disconnected.svg'; diff --git a/src/components/DocsButton.tsx b/src/components/DocsButton.tsx index e1fbd55a..52faf863 100644 --- a/src/components/DocsButton.tsx +++ b/src/components/DocsButton.tsx @@ -7,7 +7,7 @@ import { connect } from 'react-redux'; import { Action, Dispatch } from '../actions'; import { toggleDocs } from '../actions/app'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import docsIcon from './images/run.svg'; // FIXME: need proper icon type StateProps = undefined; diff --git a/src/components/Editor.tsx b/src/components/Editor.tsx index e282bfd2..3558da98 100644 --- a/src/components/Editor.tsx +++ b/src/components/Editor.tsx @@ -12,8 +12,8 @@ import { IAceEditor } from 'react-ace/lib/types'; import { connect } from 'react-redux'; import { Action, Dispatch } from '../actions'; import { setEditSession, storageChanged } from '../actions/editor'; -import { EditorStringId } from './editor'; -import en from './editor.en.json'; +import { EditorStringId } from './editor-i18n'; +import en from './editor-i18n.en.json'; import 'ace-builds/src-noconflict/mode-python'; import 'ace-builds/src-noconflict/theme-xcode'; diff --git a/src/components/FlashButton.tsx b/src/components/FlashButton.tsx index b1c38bec..fdfafc96 100644 --- a/src/components/FlashButton.tsx +++ b/src/components/FlashButton.tsx @@ -8,7 +8,7 @@ import * as notification from '../actions/notification'; import { RootState } from '../reducers'; import { BootloaderConnectionState } from '../reducers/bootloader'; import OpenFileButton, { OpenFileButtonProps } from './OpenFileButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import firmwareIcon from './images/firmware.svg'; type StateProps = Pick; diff --git a/src/components/LinkButton.tsx b/src/components/LinkButton.tsx index 3efcfa33..f795d9c1 100644 --- a/src/components/LinkButton.tsx +++ b/src/components/LinkButton.tsx @@ -4,8 +4,8 @@ import { Button, Intent, Position, Tooltip } from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; -import { TooltipId } from './button'; -import en from './button.en.json'; +import { TooltipId } from './button-i18n'; +import en from './button-i18n.en.json'; export interface LinkButtonProps { /** A unique id for each instance. */ diff --git a/src/components/Notification.tsx b/src/components/Notification.tsx index 24e58d44..8775285c 100644 --- a/src/components/Notification.tsx +++ b/src/components/Notification.tsx @@ -9,7 +9,8 @@ import { connect } from 'react-redux'; import { Action, Dispatch } from '../actions'; import { NotificationLevel, remove } from '../actions/notification'; import { Level, MessageAction } from '../reducers/notification'; -import en from './notification.en.json'; +import { MessageId } from './notification-i18n'; +import en from './notification-i18n.en.json'; interface DispatchProps { onAction: (action: Action) => void; @@ -20,7 +21,7 @@ interface OwnProps { id: number; level: NotificationLevel; message?: string; - messageId?: string; + messageId?: MessageId; replacements?: PrimitiveReplacementDictionary; helpUrl?: string; action?: MessageAction; diff --git a/src/components/OpenButton.tsx b/src/components/OpenButton.tsx index cc9ff87e..725dc6f7 100644 --- a/src/components/OpenButton.tsx +++ b/src/components/OpenButton.tsx @@ -7,7 +7,7 @@ import * as editor from '../actions/editor'; import * as notification from '../actions/notification'; import { RootState } from '../reducers'; import OpenFileButton, { OpenFileButtonProps } from './OpenFileButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import openIcon from './images/open.svg'; type StateProps = Pick; diff --git a/src/components/OpenFileButton.tsx b/src/components/OpenFileButton.tsx index 56e40340..44f1225c 100644 --- a/src/components/OpenFileButton.tsx +++ b/src/components/OpenFileButton.tsx @@ -5,8 +5,8 @@ import { Button, Intent, Position, Tooltip } from '@blueprintjs/core'; import { WithI18nProps, withI18n } from '@shopify/react-i18n'; import React from 'react'; import Dropzone, { FileRejection } from 'react-dropzone'; -import { TooltipId } from './button'; -import en from './button.en.json'; +import { TooltipId } from './button-i18n'; +import en from './button-i18n.en.json'; export interface OpenFileButtonProps { /** A unique id for each instance. */ diff --git a/src/components/ReplButton.tsx b/src/components/ReplButton.tsx index 54356cdb..44c943d3 100644 --- a/src/components/ReplButton.tsx +++ b/src/components/ReplButton.tsx @@ -7,7 +7,7 @@ import { repl } from '../actions/hub'; import { RootState } from '../reducers'; import { HubRuntimeState } from '../reducers/hub'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import replIcon from './images/repl.svg'; type StateProps = Pick; diff --git a/src/components/RunButton.tsx b/src/components/RunButton.tsx index 882849b5..af5a3986 100644 --- a/src/components/RunButton.tsx +++ b/src/components/RunButton.tsx @@ -7,7 +7,7 @@ import { downloadAndRun } from '../actions/hub'; import { RootState } from '../reducers'; import { HubRuntimeState } from '../reducers/hub'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import runIcon from './images/run.svg'; type StateProps = Pick; diff --git a/src/components/SaveAsButton.tsx b/src/components/SaveAsButton.tsx index 360e4744..1c11ddc3 100644 --- a/src/components/SaveAsButton.tsx +++ b/src/components/SaveAsButton.tsx @@ -6,7 +6,7 @@ import { Dispatch } from '../actions'; import * as editor from '../actions/editor'; import { RootState } from '../reducers'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import downloadIcon from './images/download.svg'; type StateProps = Pick; diff --git a/src/components/StopButton.tsx b/src/components/StopButton.tsx index 11b06ccb..881f5cac 100644 --- a/src/components/StopButton.tsx +++ b/src/components/StopButton.tsx @@ -7,7 +7,7 @@ import { stop } from '../actions/hub'; import { RootState } from '../reducers'; import { HubRuntimeState } from '../reducers/hub'; import ActionButton, { ActionButtonProps } from './ActionButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import stopIcon from './images/stop.svg'; type StateProps = Pick; diff --git a/src/components/SupportButton.tsx b/src/components/SupportButton.tsx index b57483b6..5e997767 100644 --- a/src/components/SupportButton.tsx +++ b/src/components/SupportButton.tsx @@ -3,7 +3,7 @@ import { connect } from 'react-redux'; import LinkButton, { LinkButtonProps } from './LinkButton'; -import { TooltipId } from './button'; +import { TooltipId } from './button-i18n'; import supportIcon from './images/stop.svg'; // FIXME: replace with correct icon type StateProps = undefined; diff --git a/src/components/Terminal.tsx b/src/components/Terminal.tsx index 7d1f0412..800cf328 100644 --- a/src/components/Terminal.tsx +++ b/src/components/Terminal.tsx @@ -13,8 +13,8 @@ import { FitAddon } from 'xterm-addon-fit'; import { Dispatch } from '../actions'; import { receiveData } from '../actions/terminal'; import { RootState } from '../reducers'; -import { TerminalStringId } from './terminal'; -import en from './terminal.en.json'; +import { TerminalStringId } from './terminal-i18n'; +import en from './terminal-i18n.en.json'; import 'xterm/css/xterm.css'; diff --git a/src/components/button.en.json b/src/components/button-i18n.en.json similarity index 100% rename from src/components/button.en.json rename to src/components/button-i18n.en.json diff --git a/src/components/button.test.ts b/src/components/button-i18n.test.ts similarity index 77% rename from src/components/button.test.ts rename to src/components/button-i18n.test.ts index 02aedfe6..74ee65ff 100644 --- a/src/components/button.test.ts +++ b/src/components/button-i18n.test.ts @@ -2,8 +2,8 @@ // Copyright (c) 2020 The Pybricks Authors import { lookup } from '../../test'; -import { TooltipId } from './button'; -import en from './button.en.json'; +import { TooltipId } from './button-i18n'; +import en from './button-i18n.en.json'; describe('Ensure .json file has matches for TooltipIds', () => { test.each(Object.values(TooltipId))('%s', (id) => { diff --git a/src/components/button.ts b/src/components/button-i18n.ts similarity index 87% rename from src/components/button.ts rename to src/components/button-i18n.ts index b2bac0fd..831c6b61 100644 --- a/src/components/button.ts +++ b/src/components/button-i18n.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors +// File: components/button-i18n.ts +// Button translation keys. export enum TooltipId { Open = 'open.tooltip', diff --git a/src/components/editor.en.json b/src/components/editor-i18n.en.json similarity index 100% rename from src/components/editor.en.json rename to src/components/editor-i18n.en.json diff --git a/src/components/editor.test.ts b/src/components/editor-i18n.test.ts similarity index 77% rename from src/components/editor.test.ts rename to src/components/editor-i18n.test.ts index d30fa97c..9c30d6c6 100644 --- a/src/components/editor.test.ts +++ b/src/components/editor-i18n.test.ts @@ -2,8 +2,8 @@ // Copyright (c) 2020 The Pybricks Authors import { lookup } from '../../test'; -import { EditorStringId } from './editor'; -import en from './editor.en.json'; +import { EditorStringId } from './editor-i18n'; +import en from './editor-i18n.en.json'; describe('Ensure .json file has matches for EditorStringId', () => { test.each(Object.values(EditorStringId))('%s', (id) => { diff --git a/src/components/editor.ts b/src/components/editor-i18n.ts similarity index 80% rename from src/components/editor.ts rename to src/components/editor-i18n.ts index 9b35e045..afa1edc8 100644 --- a/src/components/editor.ts +++ b/src/components/editor-i18n.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors +// File: components/editor-i18n.ts +// Editor translation keys. export enum EditorStringId { Placeholder = 'editor.placeholder', diff --git a/src/components/notification.en.json b/src/components/notification-i18n.en.json similarity index 100% rename from src/components/notification.en.json rename to src/components/notification-i18n.en.json diff --git a/src/components/notification.test.ts b/src/components/notification-i18n.test.ts similarity index 75% rename from src/components/notification.test.ts rename to src/components/notification-i18n.test.ts index fac84841..8f2d9729 100644 --- a/src/components/notification.test.ts +++ b/src/components/notification-i18n.test.ts @@ -2,8 +2,8 @@ // Copyright (c) 2020 The Pybricks Authors import { lookup } from '../../test'; -import { MessageId } from '../reducers/notification'; -import en from './notification.en.json'; +import { MessageId } from './notification-i18n'; +import en from './notification-i18n.en.json'; describe('Ensure .json file has matches for MessageIds', () => { test.each(Object.values(MessageId))('%s', (id) => { diff --git a/src/components/notification-i18n.ts b/src/components/notification-i18n.ts new file mode 100644 index 00000000..d036f618 --- /dev/null +++ b/src/components/notification-i18n.ts @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: MIT +// Copyright (c) 2020 The Pybricks Authors +// File: components/notification-i18n.ts +// Notification translation keys. + +export enum MessageId { + BleCannotWriteWithoutResponse = 'ble.cannotWriteWithoutResponse', + BleConnectFailed = 'ble.connectFailed', + BleGattPermission = 'ble.gattPermission', + BleGattServiceNotFound = 'ble.gattServiceNotFound', + BleNoWebBluetooth = 'ble.noWebBluetooth', + ProgramChanged = 'editor.programChanged', + ServiceWorkerSuccess = 'serviceWorker.success', + ServiceWorkerUpdate = 'serviceWorker.update', + YesReloadProgram = 'editor.yesReloadProgram', +} diff --git a/src/components/terminal.en.json b/src/components/terminal-i18n.en.json similarity index 100% rename from src/components/terminal.en.json rename to src/components/terminal-i18n.en.json diff --git a/src/components/terminal.test.ts b/src/components/terminal-i18n.test.ts similarity index 76% rename from src/components/terminal.test.ts rename to src/components/terminal-i18n.test.ts index 92705601..40fb478e 100644 --- a/src/components/terminal.test.ts +++ b/src/components/terminal-i18n.test.ts @@ -2,8 +2,8 @@ // Copyright (c) 2020 The Pybricks Authors import { lookup } from '../../test'; -import { TerminalStringId } from './terminal'; -import en from './terminal.en.json'; +import { TerminalStringId } from './terminal-i18n'; +import en from './terminal-i18n.en.json'; describe('Ensure .json file has matches for TerminalStringIds', () => { test.each(Object.values(TerminalStringId))('%s', (id) => { diff --git a/src/components/terminal.ts b/src/components/terminal-i18n.ts similarity index 71% rename from src/components/terminal.ts rename to src/components/terminal-i18n.ts index c2dca68c..c6d3345c 100644 --- a/src/components/terminal.ts +++ b/src/components/terminal-i18n.ts @@ -1,5 +1,7 @@ // SPDX-License-Identifier: MIT // Copyright (c) 2020 The Pybricks Authors +// File: components/terminal-i18n.ts +// Terminal translation keys. export enum TerminalStringId { Copy = 'terminal.copy', diff --git a/src/reducers/notification.ts b/src/reducers/notification.ts index 1bbcd71c..8bca0718 100644 --- a/src/reducers/notification.ts +++ b/src/reducers/notification.ts @@ -14,20 +14,9 @@ import { import { MpyActionType } from '../actions/mpy'; import { NotificationActionType } from '../actions/notification'; import { ServiceWorkerActionType } from '../actions/service-worker'; +import { MessageId } from '../components/notification-i18n'; import { createCountFunc } from '../utils/iter'; -export enum MessageId { - BleCannotWriteWithoutResponse = 'ble.cannotWriteWithoutResponse', - BleConnectFailed = 'ble.connectFailed', - BleGattPermission = 'ble.gattPermission', - BleGattServiceNotFound = 'ble.gattServiceNotFound', - BleNoWebBluetooth = 'ble.noWebBluetooth', - ProgramChanged = 'editor.programChanged', - ServiceWorkerSuccess = 'serviceWorker.success', - ServiceWorkerUpdate = 'serviceWorker.update', - YesReloadProgram = 'editor.yesReloadProgram', -} - /** * Severity level of notification. */