Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ jobs:
- run:
name: Babel build
command: yarn --cwd /buie build:ci:es
- run:
name: Checking locales and styles
command: /buie/scripts/check_generated_files.sh
- run:
name: Webpack build
command: yarn --cwd /buie build:ci:dist
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ dist/
es/
i18n/*.js
Comment thread
reneshen0328 marked this conversation as resolved.
i18n/bundles/
i18n/json/
node_modules/
reports/
storybook/
Expand Down
1 change: 0 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ desktop.ini
examples
flow/
flow-typed/npm/
i18n/json
jest.config.js
jsconfig.json
npm-debug.log
Expand Down
7 changes: 0 additions & 7 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import type { StorybookConfig } from '@storybook/react-webpack5';
import type { Configuration } from 'webpack';

import NodePolyfillPlugin from 'node-polyfill-webpack-plugin';
import TranslationsPlugin from '@box/frontend/webpack/TranslationsPlugin';
import _webpack from 'webpack';
import _i18n from '../scripts/i18n.config.js';

const { DefinePlugin } = _webpack;
const { translationDependencies } = _i18n;

const language = process.env.LANGUAGE;
const version = process.env.NODE_ENV === 'production' ? 'demo' : 'dev';
Expand Down Expand Up @@ -70,10 +67,6 @@ const config: StorybookConfig = {
new DefinePlugin({
__VERSION__: JSON.stringify(version),
}),
new TranslationsPlugin({
generateBundles: true,
additionalMessageData: translationDependencies.map(pkg => `${pkg}/i18n/[language]`),
}),
new NodePolyfillPlugin({
additionalAliases: ['process'],
}),
Expand Down
4 changes: 3 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ const preview: Preview = {
initialGlobals: {
locale: reactIntl.defaultLocale,
locales: Object.keys(boxLanguages).reduce((locales, language) => {
locales[language] = boxLanguages[language].name;
if (reactIntl.messages[language]) {
locales[language] = boxLanguages[language].name;
}
return locales;
}, {}),
},
Expand Down
22 changes: 15 additions & 7 deletions .storybook/reactIntl.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import boxLanguages from '@box/languages';

const messages = boxLanguages.reduce(
(bundles, language) => ({
// Webpack's require.context includes only bundle files present at compile time.
// Locales without i18n/<locale>.js are skipped by buildLanguageBundles, so Storybook
// can boot from the empty en-US catalog before Moji commits translated files.
const bundleContext = require.context('../i18n/bundles', false, /^\.\/[^/]+\.js$/);
const bundleKeys = new Set(bundleContext.keys());

const messages = boxLanguages.reduce((bundles, language) => {
const key = `./${language}.js`;
if (!bundleKeys.has(key)) {
return bundles;
}
return {
...bundles,
// eslint-disable-next-line global-require, import/no-dynamic-require, @typescript-eslint/no-var-requires
[language]: require(`../i18n/bundles/${language}`).messages,
}),
{},
);
[language]: bundleContext(key).messages,
};
}, {});

export const reactIntl = {
defaultLocale: 'en-US',
Expand Down
6 changes: 0 additions & 6 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ module.exports = {
'@babel/plugin-transform-object-assign',
'@babel/plugin-transform-object-rest-spread',
'babel-plugin-styled-components',
[
'react-intl',
{
messagesDir: './i18n/json',
},
],
],
env: {
development: {
Expand Down
File renamed without changes.
1,053 changes: 1,053 additions & 0 deletions i18n/bn-IN.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/bn-IN.properties

This file was deleted.

1,027 changes: 1,027 additions & 0 deletions i18n/da-DK.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/da-DK.properties

This file was deleted.

1,030 changes: 1,030 additions & 0 deletions i18n/de-DE.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/de-DE.properties

This file was deleted.

239 changes: 239 additions & 0 deletions i18n/en-AU.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/en-AU.properties

This file was deleted.

2 changes: 2 additions & 0 deletions i18n/en-CA.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// THIS IS A GENERATED FILE. DO NOT EDIT MANUALLY OR YOUR CHANGES WILL BE OVERWRITTEN
export default {};
2,130 changes: 0 additions & 2,130 deletions i18n/en-CA.properties

This file was deleted.

239 changes: 239 additions & 0 deletions i18n/en-GB.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/en-GB.properties

This file was deleted.

4 changes: 4 additions & 0 deletions i18n/en-US.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// THIS FILE IS INTENTIONALLY LEFT BLANK.
// Messages for the source locale are loaded from message definitions via react-intl fallback.
// DO NOT ADD ANY MESSAGES HERE!
export default {};
2,130 changes: 0 additions & 2,130 deletions i18n/en-US.properties

This file was deleted.

2 changes: 2 additions & 0 deletions i18n/en-x-pseudo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// THIS IS A GENERATED FILE. DO NOT EDIT MANUALLY OR YOUR CHANGES WILL BE OVERWRITTEN
export default {};
2,130 changes: 0 additions & 2,130 deletions i18n/en-x-pseudo.properties

This file was deleted.

1,041 changes: 1,041 additions & 0 deletions i18n/es-419.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/es-419.properties

This file was deleted.

1,041 changes: 1,041 additions & 0 deletions i18n/es-ES.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/es-ES.properties

This file was deleted.

1,049 changes: 1,049 additions & 0 deletions i18n/fi-FI.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/fi-FI.properties

This file was deleted.

1,037 changes: 1,037 additions & 0 deletions i18n/fr-CA.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/fr-CA.properties

This file was deleted.

1,037 changes: 1,037 additions & 0 deletions i18n/fr-FR.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/fr-FR.properties

This file was deleted.

1,050 changes: 1,050 additions & 0 deletions i18n/hi-IN.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/hi-IN.properties

This file was deleted.

1,043 changes: 1,043 additions & 0 deletions i18n/it-IT.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/it-IT.properties

This file was deleted.

1,053 changes: 1,053 additions & 0 deletions i18n/ja-JP.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/ja-JP.properties

This file was deleted.

1,050 changes: 1,050 additions & 0 deletions i18n/ko-KR.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/ko-KR.properties

This file was deleted.

1,045 changes: 1,045 additions & 0 deletions i18n/nb-NO.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/nb-NO.properties

This file was deleted.

1,034 changes: 1,034 additions & 0 deletions i18n/nl-NL.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/nl-NL.properties

This file was deleted.

1,051 changes: 1,051 additions & 0 deletions i18n/pl-PL.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/pl-PL.properties

This file was deleted.

1,044 changes: 1,044 additions & 0 deletions i18n/pt-BR.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/pt-BR.properties

This file was deleted.

1,055 changes: 1,055 additions & 0 deletions i18n/ru-RU.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/ru-RU.properties

This file was deleted.

1,044 changes: 1,044 additions & 0 deletions i18n/sv-SE.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/sv-SE.properties

This file was deleted.

1,047 changes: 1,047 additions & 0 deletions i18n/tr-TR.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/tr-TR.properties

This file was deleted.

1,052 changes: 1,052 additions & 0 deletions i18n/zh-CN.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/zh-CN.properties

This file was deleted.

1,049 changes: 1,049 additions & 0 deletions i18n/zh-TW.js

Large diffs are not rendered by default.

2,130 changes: 0 additions & 2,130 deletions i18n/zh-TW.properties

This file was deleted.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@
"build:prod:dist": "NODE_ENV=production webpack --config scripts/webpack.config.js --mode production",
"build:prod:es": "NODE_ENV=production BABEL_ENV=npm yarn build:es --source-maps --ignore \"**/*.d.ts,**/__tests__/**,**/__mocks__/**\"",
"build:prod:npm": "BABEL_ENV=production OUTPUT=dist LANGUAGE=en-US REACT=true yarn build:prod:dist",
"build:prod:storybook": "NODE_ENV=production BABEL_ENV=production BROWSERSLIST_ENV=production LANGUAGE=en-US REACT=true storybook build -o storybook",
"build:prod:storybook": "yarn build:i18n && NODE_ENV=production BABEL_ENV=production BROWSERSLIST_ENV=production LANGUAGE=en-US REACT=true storybook build -o storybook",
Comment thread
reneshen0328 marked this conversation as resolved.
"chromatic": "chromatic",
"clean": "rm -rf dist es i18n/bundles i18n/json i18n/*.js reports storybook",
"clean": "rm -rf dist es i18n/bundles reports storybook",
"copy:flow": "flow-copy-source --ignore \"**/__tests__/**\" --ignore \"**/__mocks__/**\" --ignore \"**/*.ts\" ./src ./es && copyfiles './src/**/*.js.flow' es --up 1",
"copy:styles": "copyfiles './src/**/*.scss' es --up 1",
"cy:open": "yarn cy:wait; yarn cypress open",
Expand All @@ -83,7 +83,7 @@
"setup": "yarn install --frozen-lockfile; npm-run-all clean build:i18n",
"start": "npm-run-all setup start:storybook",
"start:npm": "yarn setup; yarn build:dev:es",
"start:storybook": "NODE_ENV=development BABEL_ENV=development LANGUAGE=en-US storybook dev -p 6060",
"start:storybook": "yarn build:i18n && NODE_ENV=development BABEL_ENV=development LANGUAGE=en-US storybook dev -p 6060",
Comment thread
reneshen0328 marked this conversation as resolved.
"start:storybook:ci": "yarn start:storybook --ci",
"test": "NODE_ENV=test BABEL_ENV=test yarn jest -c scripts/jest/jest.config.js",
"test:e2e": "BROWSERSLIST_ENV=test npm-run-all -p -r start cy:run",
Expand Down Expand Up @@ -198,7 +198,6 @@
"babel-loader": "^9.1.3",
"babel-plugin-dynamic-import-node": "^2.3.0",
"babel-plugin-flow-react-proptypes": "^25.1.0",
"babel-plugin-react-intl": "^5.1.18",
"babel-plugin-react-remove-properties": "^0.3.0",
"babel-plugin-rewire": "^1.0.0",
"babel-plugin-styled-components": "^1.10.7",
Expand Down Expand Up @@ -393,6 +392,8 @@
"webpack-dev-middleware": "^7.4.6"
},
"msw": {
"workerDirectory": [".storybook/public"]
"workerDirectory": [
".storybook/public"
]
}
}
39 changes: 35 additions & 4 deletions scripts/buildLanguages.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,39 @@
#!/usr/bin/env node

// Remove this file and call buildBundles from @box/frontend directly when @box/frontend is upgraded to ^12.

/**
* buildLanguages.js - Generate i18n bundle files
*
* This script replaces the bundle generation that was previously done
* by TranslationsPlugin during webpack builds.
*
* Usage: buildLanguages.js [i18nDir] [--typescript]
*/

const path = require('path');
const buildLanguageBundles = require('@box/frontend/i18n/buildLanguageBundles');
const buildTranslations = require('@box/frontend/i18n/buildTranslations');
const { translationDependencies } = require('./i18n.config');

buildTranslations();
buildLanguageBundles(translationDependencies.map(pkg => `${pkg}/i18n/[language]`));
// Parse command-line arguments
// Usage: buildLanguages.js [i18nDir] [--typescript]
const args = process.argv.slice(2);
const typescript = args.includes('--typescript');

const i18nDir = args.find(arg => !arg.startsWith('--'));
const options = {
i18nDir,
typescript,
};

// Load translation dependencies from i18n.config.js in the project root
const projectRootDir = process.cwd();
const configPath = path.join(projectRootDir, 'i18n.config.js');
// eslint-disable-next-line import/no-dynamic-require
const { translationDependencies } = require(configPath);

// Transform package names to i18n paths with [language] placeholder
// Use the folder name from i18nDir if provided, otherwise default to 'i18n'
const i18nFolderName = i18nDir ? path.basename(i18nDir) : 'i18n';
const additionalMessageData = translationDependencies.map(pkg => `${pkg}/${i18nFolderName}/[language]`);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

buildLanguageBundles(additionalMessageData, options);
37 changes: 0 additions & 37 deletions scripts/check_generated_files.sh

This file was deleted.

30 changes: 3 additions & 27 deletions scripts/prepush.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#!/bin/bash

# translation properties file
PROPERTIES="i18n/en-US.properties"

# Styling variables
red=$"\e[1;31m"
green=$"\e[1;32m"
Expand All @@ -16,37 +13,18 @@ check_uncommitted_files() {
fi
}

# commit updated translations if any
check_and_commit_updated_translations() {
if ! git diff --quiet HEAD $PROPERTIES; then
printf "${red}--------------------------------------------------------${end}"
printf "${red}Committing updated translations${end}"
printf "${red}--------------------------------------------------------${end}"
git add $PROPERTIES || exit 1
git commit --amend --no-edit --no-verify || exit 1
printf "${red}--------------------------------------------------------${end}"
printf "${red}Amended commit with translations, please push again with --no-verify${end}"
printf "${red}--------------------------------------------------------${end}"
exit 1
else
printf "${green}--------------------------------------------------------${end}"
printf "${green}en-US.properties is already up to date${end}"
printf "${green}--------------------------------------------------------${end}"
fi
}

# lint, test, and build assets to update translations
# lint, test, and build assets
prepush() {

printf "${blue}-------------------------------------------------------------${end}"
printf "${blue}Building all sources, this will update i18n/json${end}"
printf "${blue}Building all sources${end}"
printf "${blue}-------------------------------------------------------------${end}"
yarn build:prod:es || exit 1

check_uncommitted_files || exit 1

printf "${blue}-------------------------------------------------------------${end}"
printf "${blue}Building localized bundles, this will update en-US.properties${end}"
printf "${blue}Building localized bundles${end}"
printf "${blue}-------------------------------------------------------------${end}"
yarn build:i18n || exit 1

Expand All @@ -55,8 +33,6 @@ prepush() {
printf "${blue}-------------------------------------------------------------${end}"
git fetch upstream
yarn test --changedSince=upstream/master || exit 1

check_and_commit_updated_translations
}

# Execute this script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`components/badge/BetaBadge should render a beta badge 1`] = `
>
<FormattedMessage
defaultMessage="BETA"
description="Text for the beta badge"
id="boxui.badges.beta"
/>
</Badge>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`components/badge/TrialBadge should render a trial badge 1`] = `
>
<FormattedMessage
defaultMessage="TRIAL"
description="Text for the trial badge"
id="boxui.badges.trial"
/>
</Badge>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exports[`components/badge/UpgradeBadge should render a upgrade badge 1`] = `
>
<FormattedMessage
defaultMessage="UPGRADE"
description="Text for the upgrade badge"
id="boxui.badges.upgrade"
/>
</Badge>
Expand Down
3 changes: 2 additions & 1 deletion src/components/time/ReadableTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export interface ReadableTimeProps {
uppercase?: boolean;
}

// exclude languages that do not have a grammar for uppercase (e.g. russian)
// Uppercase is suppressed for these locales as a product/UX choice.
// Cyrillic does have uppercase; `ru` is still excluded from ALL-CAPS.
const nonUppercaseLocales = ['ru'];
const ReadableTime = ({
intl,
Expand Down
Loading
Loading