farmOS translation (i18n)

thanks for your reply.
You are right. I used the wrong term there.
Iam using farmOS with the Germany translation and there are some translation differences in Log types and measure isnt translated (so also a “difference”).
e.g.
englisch = FarmOS = Fieldkit
Harvest = Ernten = Sammeln
Seedings = Aussaaten = Verteilen
Observations = Beobachtung = Überwachung

i dont have all modules enabled so i dont know if the list is complete.

Greetings
Andreas

Interesting. So you’re seeing translations already in Field Kit?

If so, we’re not providing that. I didn’t even know that was possible, although it doesn’t surprise me now that I think about it, especially if you’re seeing that in the PWA. It must be the browser or some other translation service. In which case there’s not much we can do about that, yea, but we are hoping to keep the Field Kit translations as much in parity with farmOS as possible. In fact, I’m going to make a note that we should make sure to search against the farmOS Portuguese translations when we begin that project this week.

Thanks again, @andifi, and keep the feedback coming! :slightly_smiling_face:

yes, but only log types ?

now iam confused :face_with_raised_eyebrow: Its also in the Android App and its depending on the modules that are enabled server-side.
the translation is not provided by Google Translate because if i enable that all text will be translated


Also the text that was already in german will be translated to other german words and make no sense anymore :roll_eyes: :crazy_face:

Huh, that’s really weird.

Can you try something for me? In a desktop browser (Firefox may be best), go to your farmOS site’s base url, make sure you’re signed in, then tack this on to the base url: /farm.json

In Firefox it should pretty-print the JSON response (or you can use a Chrome extension). Take a look under resources -> log -> farm_seeding and tell me if the label field is in English or German. I first suspected this, so I tried it on my local dev server with translations on (in Portuguese), but they were still in English. Maybe I need to try German or maybe there’s some configuration you have that I lack. But I’m very curious if you have a chance to try that what the results are.

The log types are, currently, the one piece of UI text that we get from the server, so it doesn’t seem like a coincidence that that might be the only piece getting translated somehow.

1 Like

you nailed it down. :+1:

its because the plural translations are wrong.
farmOS uses the plural and the Fieldkit App uses the singular ones

Yea, I’m noticing these discrepencies here, too: https://localize.drupal.org/translate/languages/de/translate?project=farm&status=0&release=all&search=seeding&author&context=all&limit=10&sid=0

Now I’m just curious why you’re getting those translations in JSON responses and I’m not. Maybe it’s the “Detection and Selection” settings you have configured? When I go to /admin/config/regional/language/configure, I only have the “Default” selection. Do you have “Session” or “Browser” selected or anything like that?

i didnt changed anything there. Only default is enabled.
But i changed to default langauge to german in /admin/config/regional/language and if i change that back to english all entries are english

default german:
image

default english:
image
(the types changed because i switched to my dev server :wink: )

Huh, that’s still weird. I tried the same thing, changed the default language, but didn’t see that. Maybe it’s a caching issue or something.

Well, this is very good to be aware of, all the same, especially as we move forward with Field Kit translations.

In the meantime, perhaps its worth checking on those plural labels for the German translations on localize.drupal.org, and submitting some corrections.

1 Like

@jgaehring showed me the translated strings in /farm.json - that’s a bug and should be fixed. We talked through the “right” way to do it, and /farm.json should include the untranslated strings, and defer to Field Kit to translate them (ultimately based on string translations it gets from the server, but in the short term they may be hard-coded).

1 Like

I made a bug report for it that piece, specifically: https://github.com/farmOS/farmOS/issues/336

1 Like

@mstenta i see this more as a feature then a bug.

For me it made the use of the App till now easier, because of the (mostly correctly) translated categories.

Iam not sure if i understand the discussion correctly, so correct me if iam wrong:
FieldKit will use a different translation source then farmOS, right? (if i understood it wrong ignore the rest of this post :smiley: )

Also as noted in my comment before i see the problem of different translations as a big challenge. (its hard enough to use the same translation for each word in the drupal localization…)

Maybe also another feature could be naming e.g. “Observations” different through the translation. This would then also not possible.

Wouldn’t it be really easy to get all the translated strings form farm.json for Fieldkit?

1 Like

Huh, that’s still weird. I tried the same thing, changed the default language, but didn’t see that. Maybe it’s a caching issue or something.

@jgaehring What language did you change to? If translations aren’t available for those strings in that language they won’t change.

There is also some caching in the translation strings, too, yes… so might need to clear cache.

i see this more as a feature then a bug.

@andifi I actually agree… and we may want to keep it as-is for the time being. Not sure yet…

But ultimately, the responsibility to translate should be on the code displaying the strings (Field Kit), so technically the translated strings in /farm.json is a bug… but a bug that is sort of useful right now… haha.

So yea… we’ll just need to be intentional about how/when we make that change so that it doesn’t break the “feature” (bug) you’re currently using. :slight_smile:

2 Likes

I tried both Portuguese and German, same result. So yea, maybe the cache.

At the beginning, yes. I’m not necessarily advising this approach to most folks, but we have some keen interest in having Portuguese translations sooner rather than later, to the extent that @rafaeltcc was willing to fork the code. Having a separate translations source seemed like a good compromise, compared to forking, because it would put us on the path towards integrating fully with farmOS and eventually using the same translation source. In the meantime we could experiment with an alternative source, kind of like mock data for the real thing, while we don’t really have the time or resources to do it properly.

Eh, not quite. We require the resources in /farm.json to generate log type names in Field Kit, because the server determines what log types are supported, but elsewhere, in places where we, for instance, write “My Logs”, those values are hardcoded. For the vast majority of strings in Field Kit, there’s no connection with the server because the whole UI is unique to Field Kit. It wouldn’t be hard to start adding translations for Field Kit on the farmOS side, using the localization module (in fact, it wouldn’t hurt to start doing that now, so they could be submitted to the official repo), but it’s not quite as simple a thing as piping those through /farm.json. Drupal has a whole process for generating those source translations, determined by what’s needed on each page, and creating a unique JavaScript file that the clientside code can access. I’ve posted some links in this comment over on GitHub if you want to dig into the Drupal source to understand better how that happens. We’re trying to figure out a way to hook into that process, and that will take some time and development.

1 Like

I can’t see any string translated to portuguese with everything in default. I checked admin/config/regional/language/configure and portuguese was already the default language.

@mstenta
i have a question about the drupal t() function: Should this function be used on every for the user visible string?
After translation nearly ~100% of the interface offline & in drupal translate to german still many things arent translated.
e.g. ‘What areas is this harvest taking place in?’, in Line 18 https://github.com/farmOS/farmOS/blob/7.x-1.x/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.features.field_instance.inc

Is this string translatable?
And whats about the other strings in this module?

If it is translatable: Whats the best way to get all strings translated?
Getting through the ui and then adding the t() in code?

1 Like

In theory, yes - t() should be used to wrap all strings. However, in Drupal 7 (which farmOS is built upon) - multilingual support is not perfect. It has been redesigned from the ground up in Drupal 8 (we are in the process of upgrading, but it will take months).

My general policy for translation in farmOS 1.x is: it is not “officially” supported, but I encourage the community to try if you want to! And if issues are found, I can review/merge pull requests. But my focus will mostly be on farmOS 2.x.

@deadcalf has started documenting some issues found, which may include the one you described above: Translation issue · Issue #313 · farmOS/farmOS · GitHub

Please feel free to contribute to that issue, and if you can figure out why it isn’t working and create a pull request I would be happy to review/merge!

1 Like

With regard to the code you linked to specifically, that is “Field Instance” configuration automatically exported by the Features module. If you look at the bottom of that file, you’ll see that there is a list of strings wrapped in the t() function, including the one you mentioned: https://github.com/farmOS/farmOS/blob/8e52d36315860d497e4f63c63325dd914750381d/modules/farm/farm_log/farm_log_harvest/farm_log_harvest.features.field_instance.inc#L543

I do not know how those translations work for Field Instances config, to be honest. You would need to do some research into “Drupal 7 Field Instance translation” (maybe just searching for that will reveal some clues).

1 Like

Hello.
I think it is important the translation system. The actual version of the system is a mess, i have time to work on the system for the 8.0 versión. Is there anybody working on it already? If so i have time to work and help with Any task.

1 Like

Hello, I am trying to set up FarmOS 2 for a small pilot in China. I understand FarmOS 2 does not have multi-language support yet and this is listed as a blocker item for the beta release. Love to contribute if I can. I am new to Drupal and wonder if someone can show me what it takes to build this feature.

2 Likes

Hey @stevezmn! Happy to hear you are trying farmOS out.

We haven’t done much testing with multi-languages yet, but there’s nothing stopping you from turning it on! There are a few Drupal core modules you’ll want to install, I believe they are the language, interface translation (previously called locale) and config translations modules. Some documentation on this is here: https://www.drupal.org/docs/multilingual-guide/choosing-and-installing-multilingual-modules

You will also need to install a language: https://www.drupal.org/docs/multilingual-guide/install-a-language

Once you’ve done that and have things configured, you should see some of the Drupal core interface translated into your language (assuming that others have already translated it). A nice page to test is the user profile edit page.

At this point I imagine many of the farmOS specific strings will not be translated though. You’ll likely need to translate many of our custom strings via the Drupal UI, I believe on this route admin/config/regional/translate. Roughly following these docs: https://www.drupal.org/docs/multilingual-guide/translating-site-interfaces

An important thing to note! You cannot translate a string until it has first been “displayed” when viewing a page in a non-default language. So in order to translate “asset” you just first go to a page that displays “asset”, which will then make it an option in the translate UI.

Once you translate strings locally I believe there is a way you can export and contribute them back to localize.drupal.org, however I have not done this myself!

I tried installing the Spanish translations a couple months ago (I believe right after the alpha 1 release) and found that little of the farmOS UI was translated, but I really didn’t spend much time with it & might have missed something. If you make much progress I would encourage you to start a new forum thread here and document your process, that would be really helpful! Bonus points if you post a screenshot of farmOS translated in your language :smiley:

Also keep in mind that farmOS 2.0 is still in alpha :slight_smile: We’d love for you to try it out, but it shouldn’t be used for real data just yet. This also means that some of the farmOS specific English strings in the codebase may change before a stable release & break any translations you make now.

Hope that helps… let us know how it goes!

1 Like