New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translation in farmOS 2.x: Wierd behavior #472
Comments
Thanks @SirSundays! I'll admit I'm very inexperienced with Drupal 8/9 localization, so we'll be learning together. :-) I may have a hunch what's causing this problem, though... if you would be willing to test it? Here is the line of code that is defining the "Add asset" and "Add log" (also "Add plan") link titles:
We may just need to change that line to:
Note that this also requires adding
Would you like to give that a try and see if it works? |
Oh and be sure to clear the cache after making that change so that it takes effect! |
Regarding the strange behavior you described in the forum (https://farmos.discourse.group/t/farmos-2-0-translation-localization-l10n-initiative/922/12)... it might be time to ask some people who are more experienced with Drupal localization. :-) There is a #multilingual Drupal Slack channel - might be worth asking the pros over there! |
Ok, so let's stick to this issue regarding the strange behavior. But regarding the other issue with the strange behavior (some part of it at least): I found this answer on StackExchange: https://drupal.stackexchange.com/a/271391 I will do some more research on the not appearing translation tho. |
Oh @SirSundays this actually reminds me... someone told me about a core Drupal translation issue that sounds familiar to what you described. I am looking for the issue link, but if my memory serves me it had something to do with using a language other than English as the site's default. Can you try something? Try setting the site default to English, but then override to German in your user profile. And then see if this cache clearing issue still happens? I'll see if I can find the link... |
This answer is correct. You need to "register strings" in the desired language before they can be translated. See "Register a string with the Translate interface UI" at the bottom: https://www.drupal.org/docs/multilingual-guide/translating-site-interfaces |
Ok here is the one that I was thinking of: https://www.drupal.org/project/drupal/issues/2806009 There are a few more that I found in the process though, which we may also need to be aware of:
That last one makes me wonder if this is related to farmOS's core |
@SirSundays FYI the weekly farmOS dev call is in 1 hour, if you are interested in joining! Happy to talk about some of this stuff. https://meet.jit.si/farmos-dev |
This works! I think then I found another place where we need to apply this. |
Excellent! Would you like to organize some changes (including this one) into a pull request? If you are familiar with that process... if not I'm happy to as well! |
@SirSundays I just started a PR for adding a Just a work-in-progress... haven't really tested it much yet... but maybe worth taking a look at and trying out if you have a chance! |
@SirSundays: @paul121 and I stayed on the call for a bit after you left (that's when we started the The help text for the "Selected language configuration" (
I spent some time this evening reading through the core issue thread, and this comment seems to suggest the same workaround: https://www.drupal.org/project/drupal/issues/2806009#comment-14009513
So... since this core issue seems to be a thorny one, which may not get resolved soon, I wonder if our best approach is to recommend that users do not change the default language from English, but instead change the "Selected language configuration" as described above. Maybe we could even enforce this in our |
I see that you are still doing some work on it, so maybe I will try this out next week and have a closer look at it then. |
Yes it needs a bit of work. I'll let you know... :-) |
I tried this on my running system. Seems to work fine, but the metrics and menus are not translated. (This worked once for me, don´t know why) All the subpages are tho. After loading my translation the once under configuration translation (the extra module we mentioned in the meeting yesterday) were already translated so this is already fine. After clearing the cache, I faced the same issue again. So all the farmOS translations were gone. After reporting the po-file it was back in the state as mentioned before. So most of the strings translated but not the metrics and submenus. Another big issue I faced: Should I put this in another issue or leave it here? BTW I created this issue, so we can collect all the words which need context:
Nice. |
I will do some local testing myself with the PO file you created (thanks again!) - I'll see if I can replicate the cache clearing issue and figure out what's causing it...
Yea I think this detection method does not make sense for farmOS. It is intended more for website. My plan with the |
@SirSundays Can you try something? Enable the "Session" detection method. This allows you to add I'm wondering if the cache clear is affecting the detection logic. I am testing locally with the |
OK good to know! A step in the right direction...
Ok yea I am seeing that too - as well as a number of other places like Metrics. I think once we get the overall localization config working, we can start digging into each case like this individually to debug them. Some might be related to config translations (which I haven't enabled locally yet myself), and others may be farmOS code that needs to be tweaked.
Yea agreed - we need to make this easy. That's what I hope the Before we can do that we just need to understand how everything needs to work. That's what I'm learning right now. :-) |
PS: I think I found a way that we can prevent new users from changing the default language when they install farmOS, by adding I haven't tested this yet, but in theory it will prevent the language selection screen from showing during the installation steps. |
To be honest the Metrics are fine. That`s all german you see there 😄
I already have an idea, what could be the problem with the menu. I think it has something to do with the config translation and that the default language is still English.
Let´s hope the just won`t take that long 😉 But I think we are already on a good path.
I should be able to test this today. |
I just pushed a commit to my The next things I'd like to do in it are:
|
I would really like to try this out now, but to be honest I have no real idea how to get from the repo to a working farmOS instance 😅 If could just push me in the right direction I would be very happy to test it out. |
I just pushed some new updates/functionality to that module, described here: #475 (comment)
Of course! Did you use the dev environment setup instructions originally? https://farmos.org/development/environment/ If so, then you should have a If you go into To get my
Then, you should be able to go to
With that branch checked out, if you try to install farmOS again from scratch it should ALSO skip the language selection screen, so you can't pick a different language during install. But you should see the new "farmOS Localization" module in "Optional modules". |
Thanks :D Thats what I did.
Ah ok I noticed that before but I thought its was done differently. Thanks for clearing this up. So basically whenever I want to test out a branch I get the repo in there test stuff and that's it?
Works!
Works. Session, User, and the predefined language are selected. (in that order)
So the first part works. I have a new dropdown menu where I can select the default language. But it seems to me that it doesn't have any effect. The user language is still the preferred language. Let's say my user language is german. If I then select English in the dropdown it has 0 effects.
Works too. Now I have shut down the docker containers. Deleted the db-folder and started it up again. Drupal shows me the installation screen. The first thing is "Choose language". Do I need to delete something else or is it just not working as intended? |
Generally speaking, yes... although this will only work for branches that do not need to add additional Drupal modules/libraries (eg: additions to
Hmm actually the same thing happened to me... (even using
Bummer - I was hoping the "Choose language" screen would not be displayed. I guess I need to look into that a bit deeper too... Thanks for testing these things! And thanks for the PRs you opened! I will review when I have a chance (maybe not today - we just got a foot of snow here!) |
Actually, this worked for me. Not everything again, some strings were missing, but most of the stuff got translated and I could change between en and de.
It´s great to learn new stuff here on the way.
No problem. I will also be out for a couple of days. I have to get back to do some work on the hardware I develop at the moment, but I will probably be there at the monthly call next week. So see you there. |
Ah I think I see what I did wrong. The
Hopefully that works to hide the "Choose language" step in installation. 🤞
I will investigate this next... |
Hmm OK so I think I know what's happening... and it relates to the workarounds we're employing... Our detection/selection rules basically specify that the chosen language should come first from the User, and then Selected language (setting aside the Session one for a moment). However, the User language is already set to "English" for any users that were created before translations were enabled. And when new users are created, they default to the "Site default" language... which will always be English. If you edit your user profile, you'll see that it is set to English (even after changing the "selected language"). But changing that DOES change the site's translations as expected. So, I think we need to do two things:
Re 1: we may be able to provide an option to "Automatically set existing users language to the default" when the selected language is changed. This can be a follow-up IMO. As an aside, I think I will actually disable Session by default, since it is only really necessary for testing purposes. An admin can decide to enable it if they need to. We really only need User and Selected language for normal functioning by default. |
OK! All of these are done in my
And:
That last one will optionally run a batch operation to change the "preferred langcode" of all existing users. It is disabled by default, so the admin needs to explicitly enable it to perform the operation. Getting there! :-D |
Here is the draft documentation for enabling translations: https://github.com/mstenta/farmOS/blob/2.x-l10n/docs/hosting/localization.md @SirSundays I think that should cover everything from the perspective of someone who just wants to enable and download existing translations. Next step will be to document how to contribute translations (and how to create local translations like you have been doing). I have a draft "work in progress" commit that creates the file for this. I just need to familiarize myself with the steps we need to document... |
This works. It could be a bit confusing maybe for new people if the "choose language" step is just skipped tho. I found on the internet this bit:
I really don't know if it works but I found, that this hook is already implemented in the farm profile, so maybe it would be worth a look. Not needed but would be cool. (Had some problems testing it because the farm profile wouldn't update immediately after saving and rebuilding the cache, while I was in the installation process.) Unfortunately, I can't test any further right now, because I get this error at the last installation step:
I tested this with a completely fresh instance of farmOS with the beta1 docker containers. If you didn't encounter this problem I will take a look at it on Wednesday.
Yeah, I think so too. I will further work on the german translation this week (hopefully).
Looks good to me. Maybe we should let someone have a look at it that doesn't know anything about this whole translation stuff. So I got it right that we will take the official route with localize drupal service and not go the download and import route, right?
Did you already have a look at this process? I really don't know if I made it like it should be done 😅 |
Hmm perhaps. We could certainly user
Oh hmm! I'm not sure what is causing that. I have not encountered it.
I think localize.drupal.org should be the "ultimate" goal - but I know that there is a process to getting strings accepted there, so I am also open to using PO files in the meantime! Maybe we can start a forum topic just for people to contribute/exchange PO files like the one you created. I think that will allow people to get started much faster, while we go through the process of getting them accepted in localize.drupal.org.
Not really! This is all new to me too. It seems like you have figured a lot of it out correctly. I could probably learn a thing or two from you actually. Would it be easy to summarize the steps you went through? Even just in these comments... I would be happy to take that and formalize it into the docs - as a first pass at least. Is it basically something like this?
The parts that are still fuzzy in my mind are:
|
I agree with you on that.
Hm okay, I will debug it then 👍
I can make something up in the next couple of days.
To be honest yes 😄
I hope it wont be that hard 😅 |
I took the PR out of "draft" status and requested @paul121's review. Let's get this into 2.0.0-beta2! 😄 |
@SirSundays I merged #475! I think that we can close this issue now as well, since the "weird behavior" is resolved. However you and I can continue to use this thread for discussion if we need to. Alternatively we can start a new forum topic or just communicate in the farmOS chat room - whatever works! Thanks again for your help identifying this issue, testing all this stuff, and contributing to the localization efforts!! |
@SirSundays after the dev call we found this module, which might be helpful for us: https://www.drupal.org/project/potx It it used by localize.drupal.org to extract all strings from projects hosted on drupal.org. It seems that contributing translations directly to localize.drupal.org will bypass the need to "register strings" locally. But maybe this module would be helpful locally too for finding strings? Worth a try... |
@SirSundays are you finding that the asset and log types listed under the Records menu are being translated? Or not? I'm helping another user and the asset and log types in the menu are still in English even though they are translated in other parts. I'm wondering if maybe our code needs to be tweaked to translate those menu items:
(there may be others like that) |
@mstenta Actually yes they are not translated currently, but I remember they were one time before I cleaned cache. The config is also translated for me. So that isn't the big problem. |
Ok good to know - I think I know the fix for it... I'll take a look... |
Had some busy 2 weeks but I could find a spare hour today to start getting back to translating. So as I found out, as a new member of the german translating group, I do not translate stuff right away but I give suggestions and a moderator then has to approve it. (Found here.) I already translated a lot but there are still ten pages with 50 each. So I definitely did not discover/register everything when I was doing everything in farmOS itself. 😂 I also created an issue in the german group saying that I´m currently translating everything farmOS related, so maybe that can give a boost to getting all the suggestions approved. I think I can join the dev call this week. Would be nice if we could spare another 10 minutes, to talk about translations. |
FYI I created an official bug report to track the menu translations specifically: https://www.drupal.org/project/farm/issues/3262752 |
FYI |
Some of the farmOS stuff is not translated, even when there is a translation in the po-file.
After a while, some of the translations seem to appear in the UI, but there are also some appearing in the list of missing translations after visiting their corresponding site.
I have some more details here on the forum: https://farmos.discourse.group/t/farmos-2-0-translation-localization-l10n-initiative/922/7?u=sirsundays
The only two important things that seem to be missing in the translation are on the dashboard the button in the top right corner "Add asset" and "Add log". When I click on them the right translations are displayed in the top row.
I would expect that these are the same as the ones displayed on the button. But still one is working while the other is not.
Screenshots
Here is what I mean. Everything is now translated (maybe it was because of a new browser startup (only tried to reload with clear cache)), except the button in the top right. Drupal shows 100% translation. Can't be trusted in my opinion.
Desktop (please complete the following information):
But this doesn't seem to be a major bug so don't give it too much of a priority.
-- Jan
The text was updated successfully, but these errors were encountered: