Skip to content

Create localization of strings - #2757

Merged
Don Jayamanne (DonJayamanne) merged 4 commits into
microsoft:masterfrom
rchiodo:dev/rchiodo/add_loc_m
Oct 9, 2018
Merged

Don Jayamanne (DonJayamanne) merged 4 commits into
microsoft:masterfrom
rchiodo:dev/rchiodo/add_loc_m

Conversation

@rchiodo

@rchiodo Rich Chiodo (rchiodo) commented Oct 2, 2018 •

Copy link
Copy Markdown

Creation of a new module - localize.
This doesn't use the vscode-nls and vscode-nls-dev as they
interfere with our code coverage.
Adding new strings requires adding them to the localize.ts and the
localize.nls..json files.
Future work would be to translate the nls.json files into xlf files for
the loc team to own. We'd then write a build time task to turn the
xlf files into the output nls..json files so that this code
works the same.

For #463

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • Has a news entry file (remember to thank yourself!)
  • Unit tests & system/integration tests are added/updated
  • Any new/changed dependencies in package.json are pinned (e.g. "1.2.3", not "^1.2.3" for the specified version)
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)
This doesn't use the vscode-nls and vscode-nls-dev as they
interfere with our code coverage.
Adding new strings requires adding them to the localize.ts and the
localize.nls.<locale>.json files.
Future work would be to translate the nls.json files into xlf files for
the loc team to own. We'd then write a build time task to turn the
xlf files into the output nls.<locale>.json files so that this code
works the same.
@DonJayamanne

Don Jayamanne (DonJayamanne) commented Oct 2, 2018 •

Copy link
Copy Markdown

Please could you install the following extension https://marketplace.visualstudio.com/items?itemName=EditorConfig.EditorConfig
I believe your tab space is tabs instead of spaces, as a result of this we're getting some noise in the commits (white-space changes). #Resolved

@DonJayamanne Don Jayamanne (DonJayamanne) left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor changes.
Oh yes, please could you add a news entry file.
You've indicated one exists in the PR, when there isn't one.
~Has a news entry file (remember to thank yourself!)
As you're a dev on the team, you don't need to thank your self, however we'll need a file that forms the basis for the release notes.

Comment thread src/utils/localize.ts Resolved
Comment thread src/utils/localize.ts Resolved
Comment thread src/utils/localize.ts Outdated
loadedLocale = parseLocale();

// Find the nls file that matches (if there is one)
const nlsFile = path.join(__dirname, 'i18n', `localize.nls.${loadedLocale}.json`);

@DonJayamanne Don Jayamanne (DonJayamanne) Oct 2, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using __dirname, please could you use EXTENSION_ROOT_DIR. #WontFix

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think __dirname is more appropriate. EXTENSION_ROOT_DIR means this file has to know where it is. Meaning if we move it we have to change the code. __dirname actually points to the correct location.


In reply to: 222081853 [](ancestors = 222081853)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

means this file has to know where it is.

Exactly, we must know where resources are located, instead of assuming their relative paths, relative to the source code.

Note: __dirname in this context points to out/client/utils/localize. as a result of which, the localize.nls.<local>.json files (resources) are in out directory.
These localization files are static resources and must be committed into VSC, hence it cannot sit in the ./out/... directory.

The i18n/localize.nls.<locale>.json should be placed in a special directory such as ./resources/i18n/... or ./resources/locales/, or ./localization/.... or other.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood how the output works. Didn't realize we could reference other folders.

I've switched it to all be in the package.nls..json files and for the package.nls.json to be the backup

No need to copy files to output and no need for extra json files

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejecting just to ensure this doesn't get merged, else its all good.

@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit 027832d into microsoft:master Oct 9, 2018
@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

2 participants