Open VasasA opened 5 years ago
Sorry, the second (2859) PR is bad. :cry:
...also FTR, in case that PR is closed in the future, we should not be translating variables directly by wrapping them in t()
:
...there's more to it: https://api.backdropcms.org/api/backdrop/core%21includes%21bootstrap.inc/function/t/1
Hello @VasasA 👋 ...most (all?) of the things you are translating are things that are saved in config. In such cases, the proper way to translate them is via the _config_translatables
section in the respective .json files. For an example, see https://github.com/backdrop/backdrop/blob/1.x/core/modules/system/config/system.core.json
The problem is that while things like site name/slogan and anonymous name are "unique" things that are saved in a single config file, translatable strings that belong to multiple things, like menus, content types, vocabularies etc. need to be saved in each individual config file, and there can be multiple of them.
To better explain things with examples, we'd need to have this chunk here:
"_config_translatables": [
"label"
],
...added to every single field.instance.*.json
file:
Then we'd also need this:
"_config_translatables": [
"name"
],
...added to every single filter.format.*.json file:
For layouts, it'd need to be:
"_config_translatables": [
"title"
],
...and so on for things like menus, vocabularies, user roles etc. I think that this was meant to be either done as part of #704, or as a follow-up issue (but I can't find any).
Anyway, what I mean to say is that unless I'm mistaken, the way you are approaching this in your PRs may work, but it's not the proper way. For instance, the "Body" label is the default added when you are creating a content type, but it may need to be different for each content type (although most sites won't change it TBH). There may also be other things that won't work as expected that I can't think of right now.
@herbdool and @quicksketch have more context re this I believe. Please chime in to clarify. Thanks.
There's this issue https://github.com/backdrop/backdrop-issues/issues/3515 which covers some of this but not specifically fields. Same idea though. Harder to implement so they haven't been done yet.
Just looking into the process. So as @klonos noted, the first step is to include, for example,
"_config_translatables": [
"label"
],
in the config files. We'll need to add them and also trigger locale to scan them so they can show up as translatable. That part I've tested and it works.
Then we'll either need to use https://api.backdropcms.org/api/backdrop/core%21includes%21config.inc/function/config_get_translated/1
or something similar to actually fetch the translation for display. I haven't tried to do this part yet.
Description of the bug
node.module
andstandard.install
are missing translation function calls needed for localization. Unable to translate some strings of the "Add content" page (Create Post) and the welcome page.I created two PR: https://github.com/backdrop/backdrop/pull/2858 https://github.com/backdrop/backdrop/pull/2866
(Don't watch the invalid closed PRs: 2859, 2860, 2864)
Testing:
core/profiles/standard/standard.install
file with this (2858): https://raw.githubusercontent.com/VasasA/backdrop/patch-1/core/profiles/standard/standard.installcore/modules/node/node.module
file with this (2866): https://raw.githubusercontent.com/VasasA/backdrop/patch-10/core/modules/node/node.module./files/translations
FTR, these were the respective original issues in d.org:
https://www.drupal.org/project/drupal/issues/1016006 https://www.drupal.org/project/drupal/issues/1130732
They have been closed as duplicates of either of the following:
D8: https://www.drupal.org/project/drupal/issues/2571337 D9: https://www.drupal.org/project/drupal/issues/1157426 (which the way I understand it, is basically the respective #704)