Skip to content
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

Template translate does not work as expected #1354

Closed
g4b0 opened this issue Apr 2, 2013 · 17 comments
Closed

Template translate does not work as expected #1354

g4b0 opened this issue Apr 2, 2013 · 17 comments

Comments

@g4b0
Copy link
Contributor

g4b0 commented Apr 2, 2013

What stated in documentation http://doc.silverstripe.org/framework/en/3.1/topics/i18n#usage-in-template-files doesn't work.

not working...

@UndefinedOffset
Copy link
Contributor

I wonder if its the case that language files in themes are not read, try moving it to mysite/lang/en.yml see if that works. Likely the manifest does not look in themes for language files.

@g4b0
Copy link
Contributor Author

g4b0 commented Apr 3, 2013

You're right! I moved YAML content into mysite YAML files and everything is ok, now. So it's a bug!

sake /dev/tasks/i18nTextCollectorTask 

generates the english YAML file into themes/mySimple, but SS will never read it and it's translated counterpart.

@UndefinedOffset
Copy link
Contributor

Ya i18nTextCollectorTask should be putting it into your site project for themes and not in the theme

@g4b0
Copy link
Contributor Author

g4b0 commented Apr 4, 2013

Maybe is better that theme folder is readed during translation, so it will be possible to translate templates.

@UndefinedOffset
Copy link
Contributor

Main problem with that is that themes aren't interpreted like modules, which is what i18n uses to look up the available translations. If I'm correct i18n uses getModules() from the manifest see https://github.com/silverstripe/sapphire/blob/3.0/i18n/i18n.php#L1695 for example.

@g4b0
Copy link
Contributor Author

g4b0 commented Apr 4, 2013

You're right, but themes have to be translated in some way, so I think that's a quite big SS issue.
If you release a theme you can't publish it translate into 2 or more languages, and everyone installing it have to translate it manually.

@simonwelsh simonwelsh added the 3.1 label Mar 14, 2014
@wernerkrauss
Copy link
Contributor

bump. any progress on this issue?

@wernerkrauss
Copy link
Contributor

Seems like this issue is solved in at least 3.1.6.

/dev/tasks/i18nTextCollectorTask?module=themes/mytheme collects stuff
/themes/mytheme/lang is noticed and translation files are added / used

@sminnee
Copy link
Member

sminnee commented Oct 15, 2014

@wernerkrauss are you happy for us to close the issue, then?

@g4b0
Copy link
Contributor Author

g4b0 commented Oct 28, 2014

As @wernerkrauss stated this issue seems solved in 3.1.6

@g4b0 g4b0 closed this as completed Oct 28, 2014
@g4b0
Copy link
Contributor Author

g4b0 commented Jan 14, 2015

It seems that the problem is still around in 3.1.8

@g4b0 g4b0 reopened this Jan 14, 2015
@daddymana
Copy link

I confirm that this error persists on 3.1.8 version

@chillu
Copy link
Member

chillu commented Feb 21, 2015

I've just tried this out in the 3.1 branch, works for me. Check i18n::include_by_locale(), it does a scandir($themesBase) - which has been there for a while (2011). One bug which might be related: i18n::get_existing_translations() doesn't run the same checks on /themes, so in cases where the locale ONLY exists in /themes this might be an issue. Since your example uses it, that's not applicable here though.

@krv
Copy link

krv commented Sep 14, 2016

I can confirm this bug. My /themes/mytheme/lang/nl.yml file was not recognized. When I added the same content to my mysite/lang/nl.yml file everything worked fine.

I created the translation in a template file (Includes/Navigation.ss)

<li><%t Navigation.BELGIUM "Belgium" %></li>

My nl.yml file looks as follows

nl: Navigation: BELGIUM: België

I am running the latest silverstripe version.

@dhensby
Copy link
Contributor

dhensby commented Sep 14, 2016

@tractorcow thoughts on this? You recently did work on this stuff

@tractorcow
Copy link
Contributor

Yep, there's a bug in theme language files. I've updated the string detection code considerably, but it looks like localisation in the themes folder isn't working.

You might be better to move your strings to mysite/lang for the time being until it's fixed.

chillu added a commit to open-sausages/silverstripe-framework that referenced this issue Feb 16, 2017
Regression in 4.x i18n rewrite. Can’t test this since ThemeResourceLoader hardcodes constants like THEME_DIR,
so its impossible to mock in different directory structures. Ideally this would use an application object with access
to environment variables, but that’s too much of a refactor to validate this simple fix.
@chillu
Copy link
Member

chillu commented Feb 16, 2017

I'm not sure if that's still an issue in 3.x, but it was definitely a regression in 4.x - which I've fixed with #6628

dhensby added a commit that referenced this issue Feb 17, 2017
…lang-dirs

Absolute paths for theme lang dirs (fixes #1354)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants