Replies: 4 comments 3 replies
-
It's a lot of information and I need a day or two to chew it. BUT I already have a real life issue related - both partially and directly - with the proposed changes so I'll need to dig a bit deeper into the problem. At the time of writing this I'm absolutely about introducing a dedicated Meanwhile, I need some details in order to be sure I understand exactly the proposed general concept. Just to be sure I'm on the same page. For the sake of simplicity I'll ask in the context of the second proposed solution - a configuration property.
|
Beta Was this translation helpful? Give feedback.
-
Learning how to get around apos went along with my experience with development in general and I must say I would much prefer the module approach because it is that much easier to grasp what’s going on by just looking at it. As a junior developer, any concept that deviated from a more module-oriented perspective or that required files that are too specific to approach a situation would have a learning curve that requires that much more cognitive effort. If there are no technical drawbacks in making it module-oriented, I would go for that. I believe this also helps developers from outside the apos community to spend less time reading docs and more time taking advantage of the functionality that is offered. |
Beta Was this translation helpful? Give feedback.
-
The team and I would like to see solution 2 also as it's more consistent with what is there now. |
Beta Was this translation helpful? Give feedback.
-
I agree with everyone here, solution 2 feels consistent with apostrophe. |
Beta Was this translation helpful? Give feedback.
-
Right now, when it comes to static localization — which is to say, phrases that are built into your templates or our admin UI that you want to be able to translate in JSON files — a particular module can only contribute to one namespace.
This felt good at first but it's not a good fit sometimes, especially for modules that use our "improve" feature to add custom UI to pieces, for instance. It could also be bad for modules used as base classes for other modules.
If we set the "i18n" option like this in a module like
@apostrophecms/piece-type-exporter
:And a project developer wants their own phrases in the default namespace, for their project:
... Then we have a collision. 🚗🚗 💥
Both use cases are valid but the project level module's setting for the
i18n
option wins and the phrases intended for the apostrophe namespace get stuck in the default namespace. Code that tries to findapostrophe:somePhrase
for translation will not find them.We have a solution in mind, and part of it is easy. Here is the easy part:
.json
files in a subdirectory likei18n/apostrophe
and they will automatically get contributed to that namespace..json
files placed directly in the i18n subdirectory of a module should wind up in..json
files in the i18n subdirectory of your module, they wind up in the default namespace.That's the easy part! But now here's the part where we need your opinion because there is one more setting that needs a home.
Some i18n namespaces need to be pushed to the browser for the admin UI (Vue), and some do not. We don't push everything to the admin UI because that would hurt performance.
So we need a place to declare "hey, this namespace belongs in the browser!"
But, we don't want to go right back to the problem of fighting over the right to set the
i18n
option in an "improve" module, or the original module, or a project level piece type module... et cetera.We have thought of two solutions. Please let us know which you prefer.
Solution one:
metadata.js
The first solution is to have an optional
metadata.js
file in each localization subdirectory, i.e. right ini18n/apostrophe
if that folder exists for a particular module.This looks like:
And
metadata.js
could contain:Since this file is specific to this folder, Apostrophe can understand it is not setting an option that can be overwritten. It is saying what to do with the JSON files in this folder, no matter what subclasses choose to do with their own localizations.
Solution two:
i18n
module sectionSo that's one way. Here's the other way: a new section in
index.js
.This would not be an option, it would be outside the
options
section, so Apostrophe understands it should treat it in a special way, allowing eachindex.js
in the inheritance tree to set the metadata for its own localized JSON files:In this solution, the JSON files are still organized in namespace subdirectories, but rather than introduce
metadata.js
in those subdirectories, we keep any metadata about the localizations in a newi18n
module format section, broken down by namespace.Which is best?
Honestly, we don't know for sure. Internally we don't have strong opinions on it. But maybe one of these solutions is clearly better and we're missing it.
An advantage of the
metadata.js
file is that it clearly groups that file with the .json files that honor it. An advantage of using a module format section is that it's more consistent with how we do everything else, and also translators who are asked to localize a folder of JSON files won't see a.js
file in there and get confused.What do you think? Either way we're going to move ahead next iteration, because we do need to start localizing the UI of modules like
@apostrophecms/piece-type-exporter
that require a solution to this problem.Just to be clear, either way the solution is 100% backwards compatible and you can ignore the metadata stuff if you're not shipping admin UI phrases.
Thanks for your thoughts!
Beta Was this translation helpful? Give feedback.
All reactions