Active
Project:
Drupal core
Version:
main
Component:
config_translation.module
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
28 May 2014 at 18:42 UTC
Updated:
16 Nov 2020 at 12:19 UTC
Jump to comment: Most recent
Comments
Comment #1
tstoecklerSo over in #2144413: Config translation does not support text elements with a format were currently discussing the topic of config_translation vs. l.d.o/locale as well. The solution that we agreed upon there is that you could do the following:
That would allow to translate the entire container with config_translation, but locale module and l.d.o would completely ignore it.
Something like this:
Note that this currently does not work, but the patch in the referenced issue would make it so.
Would that be of any help?
Comment #2
hass commentedI'm not sure I fully understand you, but it sounds like I must restructure my modules variable names and the "tree". This sounds very bad to me as it is not flexible.
Comment #3
hass commentedWe could also allow
translatable_setting: true. This will disable potx extraction, but still allow settings to be translatable. Than we do not need two at the same time... Just one.Comment #4
gábor hojtsy@hass: I don't think your module would ship with default settings in those site specific items. potx will only export translatable things from default configuration (config files in config/install/* in your module). So not sure what are the settings affected. Eg. you would not ship with UA codes I think.
The larger problem with trying to use config translation as a generic system for per-language settings storage is with permissions and validation, that is mostly security. To access any of the settings forms only requires one flat permissions for ALL of them. If you have that permission, you can translate views, contact forms, etc. There is no built-in way to limit this for your "translation" form. And then widgets and validation. There is some support for shipping with your own widgets and validation but you need to implement them separate from your data entry form (or somehow figure out how to make them work for both the base settings form and the translation form). I believe your UA form element has a form item prefix, it has validation on length, etc. This is not possible with the text translation system. Some of the values you want to store per language need to have their own widgets, eg. a select box for an integer value with options that make sense for the user.
So I think at best you may need to override the route permissions checking for the translatable tab and subpages if you want more stricter permissions vs. the global flat permission for config translation and implement your own config translation widget/validation integration. This is probably much more and totally on your module to do than the potx extraction problem.
Once again locale/potx only deals with default shipped configuration that is in your config/install/* directory in your modules/projects. Unless those have non-universal data (which I doubt), marking them translatable should not be an issue. However I think what you would want to use is not even translatable, but your own property that your widget can respond and provide your custom translation UI, so all you reuse from config translation would be the standard tabs, summary and overview implementation and the shell of the translation form.
Does that make sense?
Comment #5
gábor hojtsyComment #6
gábor hojtsyTo elaborate on #4 with concrete info:
type: google_analytics_settings) for the part of the config translation stuff that you want covered (it would be a container type as per #1 so definitely ignored by locale/localize.drupal.org).I don't think we even explored/thought about how this may work, so you are on uncharted territory. This may let you integrate your translation with your own form element set that can then use whatever widgets you want with whatever validation and still store the settings as a language config override. Sounds like fun to try, ha? :)
Comment #7
hass commentedWell, I do not know how to implement all these details. Missing validation and permission check sounds like problems I cannot accept myself and haven't tested yet. I'm not deep enough in D8 to implement all this stuff. One of my concerns is that we should keep the settings in the existing config files. I'm sure we do not like to re-invent the storage wheel again.
Comment #8
gábor hojtsy@hass: well, it may be problematic but as said you are trying to use this system for something it was not designed for... I think its a triumph that (if) it is even possible to do :D Also I think we may have crossposted. You can try the custom type/widget stuff and see if that works in some way for you and then delve into permissions.
Comment #9
hass commentedSome time passed away now. Has this feature implemented in a generic way in core that contrib can just re-use or may has someone started a contrib project that allows per language settings?
Comment #10
tstoeckler@hass: The issue referenced in #1 has been committed in the meantime. So it is now possible to mark container elements as translatable. The POTX integration can be controlled, by marking (or not-marking) the leaf elements of a container as translatable, similar to what I mentioned in #1.
What specifically is needed on top of that?
Comment #11
hass commentedI do not understand #1. can you explain it with a simplier example, please? I only want to allow people to translate a string variable if they have a need for it. If not needed it should use the untranslated value. It need to work like variables module with i18n under D7.
On top we need variables per domain. Same reasons for people with domain access modules. E.g. One google Analytics account per domain.
Comment #12
penyaskito@hass: If I understood #1 correctly, that is the config schema:
So your config object should look like:
This, together with that schema, would make your config objects translatable, but not visible in the locale translation form or l.d.o. Does this make sense to both of you?
Comment #13
hass commentedThe schema is at http://cgit.drupalcode.org/google_analytics/tree/config/schema/google_an...
It sounds like I'm not able to limit translatability to only some setting values this way.
How is this different to #2276343: Re-implement per language settings in D8?
Comment #14
hass commentedI need to ask again with a concrete example code. I'd like to allow
accountvariable value to be configurable per language. These are variables that are individual to every site and language and must never extracted by potx as translatable string.Is this possible with config objects? It would also not hurt if users are able to configure all values per language.
Comment #17
berdirBump :)
I think the most obvious use case for this in core would be the frontpage/404/403 pages, where you might want to have different things per language. And I think the initial suggestion here (didn't really read past that) wouldn't really work as we can't change the structure of that anymore.
http://drupal.stackexchange.com/questions/222750/different-front-page-pe... for one person asking for that.
Comment #18
tijsdeboeckThanks Berdir for bumping this, and refering to my question on Stackexchange.
I'd really appreciate a solution for this, especially for the front-, 404 & 403 pages like you said. I was very supprised when I found out it wasn't possible in D8, and can't imagine that I would be the onlyone with this question...
Comment #19
gábor hojtsyOnce again core assumes that whatever is translatable in config is interface text and is not different values per language but is something that a translator could pre-translate to a different value without knowing the site/use case. So all the translatable configs are extracted for translation to localize.drupal.org. Swapping values per language is a different question and is not supported by config translation. That said, the config override system supports overriding arbitrary values by arbitrary criteria, so it should be relatively easy to write a contributed module to do that.
Comment #20
berdir@Gabor: Why can't we introduce a new type or something for string-that-might-be-localized and allow to translate it without triggering the locale sync?
Comment #21
gábor hojtsyI think we can if there are people interested in / have time to work on it.
Comment #22
andypostI think a case of 403/404 is not good example here, because 404 in case of domain module could cause wrong language negotiation
btw this should be done on top of config overrides, probably a contrib module makes sense
Comment #25
asgorobets commentedHere is an attempt to add support for this in contrib: #2914987: Language-specific overrides support
But I feel like having the system in core and potentially reusing the same UI that config_translation has would be way better than asking people to mess with yml files.
Comment #27
mpp commentedNote that the configuration API documents the
translatableproperty as:See https://www.drupal.org/docs/8/api/configuration-api/configuration-schema...
Given the fact that this issue is a bug we may need to indicate in the documentation that it currently only works for label and string types?
Comment #31
andypostComment #33
pasqualleAfter thinking about this feature it seems like a good solution, which seems to be fairly easy.
I have some questions related to this feature:
1. Should it be "translation_export" or "translation export"?
What is the best practice for config property names regarding underscore vs space?
We have "translation context", so I would expect unification. But it seems "translation context" should be with underscore also, as underscores are more common with core config.
2. Should be the "type: path" config translatable by default, and exception "translatable: false" used when it really should not be translated? There are lot of path configs in core, where most of them should be translatable.
3. Why is date_format translatable and first_day is not translatable? I guess both should be: