Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add metadata to supportedOptions for passing additional info #230

Merged
merged 10 commits into from
Jun 16, 2022

Conversation

mmohajer
Copy link
Contributor

@mmohajer mmohajer commented May 3, 2022

The purpose is to add an option to the list of supportedOptions in order to be able to pass any additional information regarding the string. This new options is called metadata and we can pass it as an object. For example, let's say we want to associate different tags to the strings. Using this new options we can have something like this:

t("Translate me {{count}} times", {count: 100, metadata: {tags: ['tag1', 'tag2']}})

Note that what we define for metadata is a custom object based on the information we want to pass and in the above example, we used tags.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included

Screen Shot 2022-06-15 at 9 58 43 AM

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided

@mmohajer
Copy link
Contributor Author

mmohajer commented Jun 8, 2022

Hi @sitek94 @cheton! I noticed you were the recent contributor/reviewer and I was wondering if you guys could give me some info on how I can add reviewers for this PR and get some eyes on it. It seems I don't have access to add reviewers. Thanks!

@sitek94
Copy link
Contributor

sitek94 commented Jun 8, 2022

Sorry @mmohajer, I have no idea 🤷 I'm not a regular contributor. I opened a small PR some time ago with a tiny docs change :)

@cheton
Copy link
Member

cheton commented Jun 9, 2022

Hi @mmohajer,

Sorry for that I don't quite understand your purpose of adding external options, because I cannot find the differences according to your new test case and was unable to find any i18next docs related to the collection key.

Can you explain that in more detail and update the test cases to see how it works? Thanks.

@mmohajer
Copy link
Contributor Author

mmohajer commented Jun 14, 2022

Hi @mmohajer,

Sorry for that I don't quite understand your purpose of adding external options, because I cannot find the differences according to your new test case and was unable to find any i18next docs related to the collection key.

Can you explain that in more detail and update the test cases to see how it works? Thanks.

Hi @cheton!

Thank you for your comment. The new option is externalOptions and we can pass a custom object in order to provide additional information about the strings. "collection" was just a sample option I used in this example:

t("Translate me {{count}} times", {count: 100, externalOptions: {collection: ['group1', 'group2']}})

Basically, the object we pass as externalOptions is based on the custom information we want to provide about that string. A better example would be tags. Let's say we want to associate strings with different tags, using this new option we can do that.

t("Translate me {{count}} times", {count: 100, externalOptions: {tags: ['tag1', 'tag2']}})

I updated the description and the test case for more clarity. Please let me know if you have any other feedback. Thanks!

@cheton
Copy link
Member

cheton commented Jun 15, 2022

Thanks for your explanation. I'm just thinking about the key name. How about using metadata instead of externalOptions?

webguy-github-ssh-key added 2 commits June 15, 2022 09:54
@mmohajer mmohajer changed the title Feat/add external options support Feat/add metadata to supportedOptions for providing additional information about the string Jun 15, 2022
@mmohajer mmohajer changed the title Feat/add metadata to supportedOptions for providing additional information about the string Feat/add metadata to supportedOptions for passing additional information Jun 15, 2022
@mmohajer
Copy link
Contributor Author

Thanks for your explanation. I'm just thinking about the key name. How about using metadata instead of externalOptions?

I updated the key name. Thanks for the feedback @cheton!

@mmohajer mmohajer changed the title Feat/add metadata to supportedOptions for passing additional information Feat/add metadata to supportedOptions for passing additional info Jun 15, 2022
@codecov
Copy link

codecov bot commented Jun 16, 2022

Codecov Report

Merging #230 (06a5c77) into master (ceb4c2c) will increase coverage by 0.04%.
The diff coverage is 95.00%.

@@            Coverage Diff             @@
##           master     #230       /-   ##
==========================================
  Coverage   91.13%   91.17%    0.04%     
==========================================
  Files           6        6              
  Lines         564      578       14     
==========================================
  Hits          514      527       13     
- Misses         50       51        1     
Impacted Files Coverage Δ
src/parser.js 90.38% <95.00%> ( 0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ceb4c2c...06a5c77. Read the comment docs.

@cheton cheton merged commit 8b5407c into i18next:master Jun 16, 2022
@cheton
Copy link
Member

cheton commented Jun 16, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants