Non-English lang strings distributed with Themes & Plugins aren't loaded.

Bug #1417120 reported by Gilles-Philippe Leblanc on 2015-02-02
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Mahara
Medium
Robert Lyon
1.10
Medium
Robert Lyon
15.04
Medium
Robert Lyon
15.10
Medium
Robert Lyon

Bug Description

Based on the doc here:
https://wiki.mahara.org/index.php/Customising/Themes/1.10#Theme_lang_strings

Theme language strings work in English, but non-English theme language strings are not loaded.

To reproduce:
1. On a custom theme add a French lang string like explained here:
https://wiki.mahara.org/index.php/Customising/Themes/1.10#Theme_lang_strings

2. Change your language to French

Expected:
The French lang string should be used

Actual:
The French lang string is not used

summary: - lang no used in theme
+ non-english lang no used in theme

Hi!

Thanks for the bug report. I found that this functionality does work for me, though, in Mahara 1.10 and 15.04dev.

I've attached a quick test theme that I whipped up that demos this functionality. All it does is replace the dashboard help text with a big "My test string".

If you're still having the problem, can you please supply a copy of a theme that demonstrates the issue?

Cheers,
Aaron

Aaron Wells (u-aaronw) wrote :
Changed in mahara:
status: New → Incomplete

Hi,

First, thanks for the quick feedback.

The problem is that a non-english custom string will not be used. The english string works OK.

In your langtest theme, add for exemple a fr.utf8 folder or the language of your choice, add the "theme.langtest.php" file in it and install in your system the language pack. The strings in the non-english language will note be used.

I found a workaround. Put the "theme.langtest.php" with the good lang folder in the htdocs/local/lang folder and it will work.
Buts its not the way it should work based on the documentation.

Aaron Wells (u-aaronw) on 2015-02-03
description: updated
Aaron Wells (u-aaronw) wrote :

Okay, I see. The problem is specifically with multilingual support for theme language files. I was able to replicate this problem.

To replicate:

1. Install the attached "langtest" theme into your Mahara site.
2. Set up the French language pack (from langpacks.mahara.org) on your Mahara site.
3. Log in to Mahara.
4. Select the French language, and the "Lang String Test" theme.

Expected result: On your dashboard page, you should see the French lang string "Ce est ma chaîne de test.".

Actual result: On your dashboard page, you see the English lang string "This is my test string".

Aaron Wells (u-aaronw) wrote :

Hm, on further investigation it looks like this is actually how *other* plugins work as well, not just themes. I had thought that lang strings were the same as theme assets now are, that they could live under the plugin directory. But the code actually doesn't look there. It *only* looks in these locations (in order):

1. <DOCROOT>/local/lang/<LANG>.utf8/theme.<THEMENAME>.php
2. <DATAROOT>/langpacks/<LANG>.utf8/theme/<THEMENAME>/lang/theme.<THEMENAME>.php
3. <DOCROOT>/local/lang/en.utf8/theme.<THEMENAME>.php
3. <DOCROOT>/theme/<THEMENAME>/lang/en.utf8/theme.<THEMENAME>.php

So, we should update the documentation accordingly. And fix the code so that it checks for lang files inside the plugin & theme directories themselves (much like we now do with themes). This'll make it much easier to distribute plugins & themes for multilingual audiences.

For the time being, your workarounds are to copy the theme lang files into the langpacks directory in your dataroot, or into the local directory as you've noticed.

Cheers,
Aaron

summary: - non-english lang no used in theme
+ Non-English lang strings distributed with Themes & Plugins aren't
+ loaded.
Aaron Wells (u-aaronw) wrote :

Hm, while I'm looking at it, it appears there's also no support for plugin lang strings in parent languages.

Maybe sometime before 15.04 I can just clean up the whole messy & old get_string() function set...

Reviewed: https://reviews.mahara.org/4779
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/1d7a1fa4252bd4c07d4277bf6a54bf354fbe1471
Submitter: Aaron Wells (<email address hidden>)
Branch: master

commit 1d7a1fa4252bd4c07d4277bf6a54bf354fbe1471
Author: Robert Lyon <email address hidden>
Date: Wed May 20 10:44:06 2015 +1200

Allowing for non english theme / plugin lang files to be used

Bug 1417120

The language location check now goes in this order:

1. /local string in selected language
2. theme/plugin directory, in selected language
3. langpack, in selected language
4. /local string in parent language (if any)
5. theme/plugin directory, in parent language
6. langpack, in parent language
7. /local string in English
8. theme/plugin directory, in English

Change-Id: I24f61e24fadbca3a62fefa3855f4f444165d750a
Signed-off-by: Robert Lyon <email address hidden>

Mahara Bot (dev-mahara) wrote :

Patch for "1.10_STABLE" branch: https://reviews.mahara.org/4806

Reviewed: https://reviews.mahara.org/4806
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/bd57c52258d01d21f9e6720ce25819b15eb43d8f
Submitter: Robert Lyon (<email address hidden>)
Branch: 1.10_STABLE

commit bd57c52258d01d21f9e6720ce25819b15eb43d8f
Author: Robert Lyon <email address hidden>
Date: Wed May 20 10:44:06 2015 +1200

Allowing for non english theme / plugin lang files to be used

Bug 1417120

The language location check now goes in this order:

1. /local string in selected language
2. theme/plugin directory, in selected language
3. langpack, in selected language
4. /local string in parent language (if any)
5. theme/plugin directory, in parent language
6. langpack, in parent language
7. /local string in English
8. theme/plugin directory, in English

Change-Id: I24f61e24fadbca3a62fefa3855f4f444165d750a
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 1d7a1fa4252bd4c07d4277bf6a54bf354fbe1471)

Mahara Bot (dev-mahara) wrote :

Reviewed: https://reviews.mahara.org/4805
Committed: https://git.nzoss.org.nz/mahara/mahara/commit/1a691a9854455903f014192316cd3c7116986c4d
Submitter: Aaron Wells (<email address hidden>)
Branch: 15.04_STABLE

commit 1a691a9854455903f014192316cd3c7116986c4d
Author: Robert Lyon <email address hidden>
Date: Wed May 20 10:44:06 2015 +1200

Allowing for non english theme / plugin lang files to be used

Bug 1417120

The language location check now goes in this order:

1. /local string in selected language
2. theme/plugin directory, in selected language
3. langpack, in selected language
4. /local string in parent language (if any)
5. theme/plugin directory, in parent language
6. langpack, in parent language
7. /local string in English
8. theme/plugin directory, in English

Change-Id: I24f61e24fadbca3a62fefa3855f4f444165d750a
Signed-off-by: Robert Lyon <email address hidden>
(cherry picked from commit 1d7a1fa4252bd4c07d4277bf6a54bf354fbe1471)

Robert Lyon (robertl-9) on 2016-11-06
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers