17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1972 Views |
-
need basic multilangual content help

27 February 2008 at 6:43am
Hi all,
This a basic question on multilangual content with SS. I have a used car website to manage. There is a list of car model with picture, description and some other infos. The translation work fine in the cms. But what if i want to translate some static field title without the cms admin. For example: The value of a Kilometer field is handle buy the cms, but i want to translate the title "Kilometer" without the cms. Sorry for my bad english and hope i made myself clear.
thx. -
Re: need basic multilangual content help

1 March 2008 at 2:06am Last edited: 1 March 2008 2:08am
This is what I do:
<?php
/**
* Returns the current language
* Should either be the string 'en' or 'es'
*/
function CurrentLang() {
return Translatable::current_lang();
}
?>That will return the current two-letter language code (en, es, fr, jp, de etc).
You can also just call current_lang in the templates, but that's a little slower.
So you would use it like this in the templates: <% if CurrentLang = en %>something<% end_if %>
Also, if you want it to be in multiple languages, this might be better:
<% _t(STRING, Some string here) %>
Then you can define "STRING" in the $lang arrays inside the lang/ directory of your project, just like the _t() calls all throughout the rest of sapphire. Take a look at some of the templates in sapphire/templates to see how that's done.Hope that helps!
-
Re: need basic multilangual content help

30 October 2008 at 8:23am Last edited: 30 October 2008 8:24am
I'm confused
I try to make strings translatable but it doesn't work for me.. Translations in CMS works, translation in template with CurrentLang works but when I put the string, from lang array comes translation only for 1 language and other labguages shows default text from string.
In config I have this:
i18n::enable();
i18n::set_locale('lt_LT');
i18n::set_default_lang('lt');
HTTP::set_cache_age(0);In page:
function CurrentLang() {
return Translatable::current_lang();
}Currently in template I have this:
<% if CurrentLang = lt %>tralialia<% end_if %>
But I want to have this:<% _t('STRING' , 'tralialia') %>
I created catalog 'lang' in 'mysite' and created files for lang array in different languages.
Where can be my mistake?
-
Re: need basic multilangual content help

10 November 2008 at 3:53am
So, the <% _t() %> call is not resolved by the template parser? Or does it show the default language string instead of the translation?
Did you use the textcollector to create your /lang files? Not 100% necessary, but can help to avoid mistakes. See http://doc.silverstripe.com/doku.php?id=i18n&s=textcollector
| 1972 Views | ||
|
Page:
1
|
Go to Top |


