Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Issue 29 - Handle multiple YML files for translations #88
Issue 29 - Handle multiple YML files for translations #88
Changes from 6 commits
be01b27
81f790f
4e4f673
f8bb20c
8f6d9b0
4381987
c56b21f
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
sourceFile
under 'de' with a value not starting with 'de.' is unrealistic.The first dot-separated segment of the last portion of the file's path is used as language identifier by the real YamlTranslationAdapter.
See also the test
can update translations before getTranslations()
below.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
sourceFile
under locale identifierde
with a value not starting withde.
is unrealistic.The first dot-separated segment of the last portion of the file's path is used as locale identifier by the real
YamlTranslationAdapter
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test also covered that
updateTranslation
does not add any other properties to the objects in the maps returned bygetTranslations
. TypeScript already enforces that so there is no problem with losing that coverage here.This is just a note from my review that I thought might be interesting. You can resolve the conversation when you have read it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cloning is no longer necessary as language is already a MessageMap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
String.prototype.replace
only replaces the first occurrence if pattern is a string.For example
getShortId('a.b.c.d', 'a/b/c/sv.yml')
should return just 'd' but this implementation returns 'c.d'.Fortunately, there is another function
replaceAll
that works as expected.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code overestimates how much of the message id comes from the path. The filename --- the last segment of the path, typically contains a dot, for example in 'sv.yml' but can in theory contain more dots too, for example 'sv.skånska.yaml'.
For example
getShortId('a.b.c', 'a/sv.yml')
should return 'b.c' but this implementation will return just 'c'.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is complex enough that it should have a somewhat extensive test suite.