Skip to content

Commit

Permalink
[RNMobile] Introduce improvements to i18n related scripts (#37787)
Browse files Browse the repository at this point in the history
* Prevent ignoring error logs from i18n command

* Fix linting issues when generating i18n index file

* Remove string replacement on makepot command output

* Update log message on generate pot files script
  • Loading branch information
fluiddot committed Jan 11, 2022
1 parent 15bef9d commit c3e1c13
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions packages/react-native-editor/bin/generate-pot-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ function make_pot () {
# In order to detect parse errors, we need to use the "--debug" option, otherwise "make-pot" command doesn't output errors.
local full_command="$makepot_command $source --debug $arguments"
if [[ -z ${DEBUG:-} ]]; then
# When DEBUG flag is not enabled, we only print the parse errors.
$full_command 2> >(grep 'Could not parse file' | sed 's/Debug[[:space:]][(]make-pot[)]/Warning/g' >&2)
# When DEBUG flag is not enabled, we ignore extra debug information except important warnings.
local ignore_pattern="Parsing file\|Debug (commands)\|Debug (bootstrap)\|Debug (hooks)"
$full_command 2> >(grep -v "$ignore_pattern" >&2)
else
$full_command
fi
Expand Down Expand Up @@ -151,7 +152,7 @@ function generate_pot_files() {
mkdir -p $output_path

if [ -n "$subtract_pot_files" ]; then
echo "--- Strings from ${plugins_to_subtract[@]} plugins will be subtracted ---"
echo "-- Strings from ${plugins_to_subtract[@]} plugins will be subtracted --"
fi

echo -e "\nExtract used strings from Android source-map:"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ const getUsedStrings = ( usedStringsFile, domain ) => {

const generateIndexFile = ( translations, pluginDir ) => {
const indexNative = `/* THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. */
/* eslint-disable prettier/prettier */
/* eslint-disable prettier/prettier */
const translations = {
${ translations
Expand All @@ -211,8 +211,8 @@ const generateIndexFile = ( translations, pluginDir ) => {
export const getTranslation = ( locale ) => translations[ locale ];
/* eslint-enable prettier/prettier */
`;
/* eslint-enable prettier/prettier */
`;

fs.writeFile(
path.join( pluginDir, 'index.js' ),
Expand Down

0 comments on commit c3e1c13

Please sign in to comment.