Untranslated strings in Lab_test log form and Birth_log form

Created on 26 June 2024, 6 months ago
Updated 17 July 2024, 5 months ago

Problem/Motivation

I am translating all of FarmOS user interface into tamil language. Here i couldn't translate some sting. That are `Date sampled` and `The date when the sample was collected.` in add Lab test log form page and `Children` and `Which child assets were born?` in add birth log form page.

Steps to reproduce

You may add language in language list on [http://example.com/admin/config/regional/language]. After custom translation sting against user interface in [admin/config/regional/translate]. Here you can know the above mentioned strings not found.

Proposed resolution

That above mentioned Lab test strings are in code[https://github.com/farmOS/farmOS/blob/3.x/modules/log/lab_test/farm_lab_... and birth log code in [https://github.com/farmOS/farmOS/blob/3.x/modules/log/birth/farm_birth.p.... Here need to wrap the string by translation function. Thank you.

🐛 Bug report
Status

Closed: cannot reproduce

Version

3.2

Component

Farm Logs

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @aathi179
  • Assigned to sourav_paul
  • Issue was unassigned.
  • Status changed to Needs review 6 months ago
  • Status changed to Closed: cannot reproduce 5 months ago
  • 🇺🇸United States m.stenta

    Sorry @aathi179 and @Sourav_Paul but I can't reproduce this on a fresh installation of farmOS. I can see all of the strings you mentioned as translatable in admin/config/regional/translate.

    However, I may have a clue as to what's happening... Are you experiencing it on an existing installation? Can you test it on a fresh installation as well to see if it works there?

    These strings actually come from two different places. For new installations, they come from these config entities:

    https://github.com/farmOS/farmOS/blob/3.x/modules/log/birth/config/insta...

    https://github.com/farmOS/farmOS/blob/3.x/modules/log/lab_test/config/in...

    Those are "base field override" configuration entities, which are used to override base field configurations. For more background, see https://www.previousnext.com.au/blog/overriding-base-field-labels-and-de...

    However, config entities provided in a module's config/install directory are only installed when the module is installed for the first time. So, when we added those config entities in farmOS core, we also needed to provide update hooks to create them on existing sites. That is what the two hook_post_update_NAME() implementations that you pointed to are for.

    Strings that are part of configuration entity YML files do not need to be wrapped in t() functions to make them translatable. The Drupal core config_translation module makes all config entities translatable. But, perhaps we do need to wrap them in t() when we create configuration entities in update hooks.

    If so, then your MR makes sense, but it would not solve the problem for users of existing sites who have already run those update hooks. So it is not a complete fix. I think the only way to do it would be to create a second update hook (in both modules) which loads the config entity, changes the string to be translatable, and then saves them again.

    However, we need to be careful. If the user has already overridden the strings we don't want to throw away their overrides. This is probably unlikely, but it is our responsibility not to break things for downstream users. So the new update hooks would need to check to make sure that the entities are using the default strings before making any changes to them.

    All of this assumes that my hunch is correct, and that this issue is only happening on existing sites that ran those update hooks. That needs to be confirmed first.

    It's up to you if you want to dig further into this. But it may be easier to just fix the issue in your own instance manually. We can rest assured that new installations of farmOS will not be affected by this issue.

Production build 0.71.5 2024