feat: Plurals - #58
Conversation
Codecov Report
@@ Coverage Diff @@
## master #58 +/- ##
==========================================
+ Coverage 95.12% 96.04% +0.92%
==========================================
Files 4 25 +21
Lines 82 354 +272
Branches 23 144 +121
==========================================
+ Hits 78 340 +262
- Misses 4 13 +9
- Partials 0 1 +1
Continue to review full report at Codecov.
|
|
smirks @d3viant0ne :) |
michael-ciniawsky
left a comment
There was a problem hiding this comment.
All question are purely naive atm as I'm not really suited to review this :), but we should definitely push this forward
| - `optionsObj.functionName`: the default value is `__`, you can change it to other function name. | ||
| - `optionsObj.failOnMissing`: the default value is `false`, which will show a warning message, if the mapping text cannot be found. If set to `true`, the message will be an error message. | ||
| - `optionsObj.hideMessage`: the default value is `false`, which will show the warning/error message. If set to `true`, the message will be hidden. | ||
| - `optionsObj.pluralIdentName`: the default value is `count`, which will be used to determine whether key is plural or not. |
There was a problem hiding this comment.
Possible to merge this a one option e.g options.plurals
options.plurals = {
identName: 'count',
ruleNumber: 1
}Are identName && ruleNumber standardize names for plurals ?
There was a problem hiding this comment.
I'm not certain about names. Just used something that is related to the stuff :)
Plural rule is used to choose the proper grammar form and there are plenty of them: https://developer.mozilla.org/en-US/docs/Mozilla/Localization/Localization_and_Plurals
I guess we can use pluralRule instead as in the guide.
And the identName is more related to the parsing stuff. I need the way to tell the difference between plural and singular keys. In our company we usually use the particular variable name for the plurals.
| @@ -0,0 +1,6 @@ | |||
| // Families: Asian (Chinese, Japanese, Korean), Persian, Turkic/Altaic (Turkish), Thai, Lao | |||
There was a problem hiding this comment.
For all these rules there isn't a sophisticated lib available ?
There was a problem hiding this comment.
I haven't checked actually. The main idea was to have small functions, so it could be easier to inline them and to have a smaller resulting bundle.
| return interpolate; | ||
| } | ||
|
|
||
| export default createInterpolateFn; |
There was a problem hiding this comment.
export default (fn) => interpolate
| moduleJsPath = `./${moduleJsPath.replace(/\\/g, '/')}`; | ||
| } | ||
|
|
||
| return `require(${JSON.stringify(moduleJsPath)}).default`; |
There was a problem hiding this comment.
Is there a way to ES2015 Syntax here e.g hoisting import
`import module_${i} from ${moduleJsPath}`
...
`${module_[i]}`
Plural and Parametrized keys
Adds support of plural and parametrized keys (issue #1).
The modern version of #42