joe_g Posted December 17, 2024 Posted December 17, 2024 Hey experts, I ran into this today: A client has a site with lots of languages (12). I just learned about multilingual fields where any field can become multilingual, which is great. My problem is that I don't know what languages the client want to make language-specific images for. In most cases the default images-field is fine, but sometimes there is a secondary language (in this case Spanish). Is there a way I can allow the client to add a language to a multilanguage field? Perhaps a combo of repeater and images field, or some sort? I suppose I could create a version for every language. The drawback is that I would have to remember to update this field in parallel with the real languages. If the client adds polish tomorrow, I would have to add a polish alternative version of these images. It's not the end of the world, and that is probably what I will end up doing, just curious if there is more neat way? thanks!
ngrmm Posted December 17, 2024 Posted December 17, 2024 You could use a hook to create those new fields and add them to certain templates.
da² Posted December 19, 2024 Posted December 19, 2024 (edited) On 12/17/2024 at 4:31 PM, joe_g said: In most cases the default images-field is fine, but sometimes there is a secondary language (in this case Spanish). Is there a way I can allow the client to add a language to a multilanguage field? I didn't play with multilanguage image fields, but if it's the same behavior than with other multilanguage fields (probably) you have nothing to do: if a multilanguage field defines a value for the current user language, then this value is used, otherwise the default language value is used. EDIT : hmm, looks like there's no multilanguage image field, so language alternate fields looks like the only solution, and then a hook like @ngrmm proposed sounds good. Edited December 19, 2024 by da² 1
virtualgadjo Posted December 29, 2024 Posted December 29, 2024 hi, in a two languages website, of course i would use two fields and use the specific one if filled, in your case i would probably tend to use a naming convention with _iso for each languageexecpt for the default one, this way, parsing your fields, it's easy to check if toto_pl.jpg exisits, if not, just use toto_jpg, it would work for any language number and, as it's easy to retreive the used languuages iso even if your client suddenly decides to add a new one and more, give your client the good habit to get used to naming convention 🙂 have a nice day
joe_g Posted January 6 Author Posted January 6 Thanks everyone. In the end I went for the most basic solution. It doesn't happen very often so i just add the language alternatives as they are needed. In this case it was field_es, next month it might be field_pl. It's so easy to do so, so in the end not a point to automate.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now