-
Notifications
You must be signed in to change notification settings - Fork 12
Provide support for translating plural forms #334
Conversation
…ereated from the message context and the message string if both are provided.
…t determines the plural forms was not provided.
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.
In general the code is fine but I am not happy with docs.
Especially two things:
- There are no new docs for
t()
. - There is no word about context.
Also, please change String[]
to Array.<String>
in docs.
When you will write new docs, please remember about an example that has plural forms and multiple values to interpolate and mention that the first value will be used for choosing a plural form.
I also don't like docs for translate()
-- it is not your fault, somebody wrote them in a messy way earlier. I would reword them but honestly, I am not sure where this method is used, so before we waste time for those docs, let's think if there will be any gain in improving them.
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.
Some changes in docs.
Fixed API docs. Co-Authored-By: Szymon Cofalik <s.cofalik@cksource.com>
I used the cc @scofalik |
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.
Interesting to see that you decided to handle such a tricky case as multiple plural version - what is use case for it? 🙂
ckeditor5-utils/src/translation-service.js
Lines 77 to 79 in 33acb99
if ( !window.CKEDITOR_TRANSLATIONS[ language ] ) { | |
window.CKEDITOR_TRANSLATIONS[ language ] = {}; | |
} |
- why did you go with the
string
+context
prop combo rather than proposedid
property in the end?- I'm a little tentative about using
context
+string
to build a translation id, as context seems to be prone to changes during product lifetime (like, stupid "a", "an", "the" changes). Instead I think that id will be a better option, and since we'll have to inline all contextes, why not inlining all the ids in a single run?
- I'm a little tentative about using
This is a major change and getting it from the API docs alone is rather difficult task. We should add a guide/doc on i11n matter, which would include feature added with this PR. It's a perfect moment to add this guide in this release (ofc should be a followup task).
There's a lot of use cases in our track changes code where the
You mean the whole format of the
The And why it's no
I was thinking about it too. There're a few things worth noting. We have an internal guide (which is going to be outdated after this task). There's a guide for setting the UI language - https://ckeditor.com/docs/ckeditor5/latest/features/ui-language.html, but we lack a guide for a 3rd-party plugin creator. |
As far as id is concerned... Isn't it a problem right now as well? You introduce some translation as What I don't like about id is that it is repeating the same information again :S. EDIT: BTW. we are not going to inline all contextes. We will still keep some of them in context.json. |
Yes, but only for message strings as message contexts (longer and therefore changing more often) are kept in Actually having the |
Co-Authored-By: Marek Lewandowski <mlewand@users.noreply.github.com>
That's why I chose this new interface for the |
If you think it is correct, go with it. |
👍
That's right, change of structure in this global variable is a BC. So needs to be reflected in changelog.
Guide task extracted to ckeditor/ckeditor5#6646 - this is something we can get back to later on. |
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.
Couple of last suggestions, LGTM.
Co-Authored-By: Marek Lewandowski <mlewand@users.noreply.github.com>
Suggested merge commit message (convention)
Feature: Provided support for plural forms internalization. Part of ckeditor/ckeditor5#6526.
MINOR BREAKING CHANGE: The
translate
function from thetranslation-service
was marked as protected. See #334.MINOR BREAKING CHANGE: The format of translations added to the editor has been changed. If you use
window.CKEDITOR_TRANSLATIONS
please see #334.Additional information
The
translate
function in thetranslation-service
was marked as protected and renamed to_translate
. All features depending on the translation mechanism should use theLocale#t()
function instead.The new format of the
window.CKEDITOR_TRANSLATIONS
: