News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Text Strings in Themes

Started by forsakenlad, September 12, 2008, 05:24:04 PM

Previous topic - Next topic

forsakenlad

As per the Theme Approval Guidelines, all text should be in a theme language string, however the Guidelines are lenient with copyrights and allow these to be hard-coded.

Theme authors will commonly place their strings into the wrong file, for example:  Modifications.language.php (Eg: Modifications.english.php, Modifications.turkish.php). Although this is not technically the wrong place to put the strings, it will cause issues with modifications being installed on the theme.

When making a theme you can simply add 2 or 3 extra lines of code into your index.template.php, which will call a ThemeStrings.language.php file where your strings can go. This will prevent conflicts with modifications and your theme.

Search for this in index.template.php:


   /* Show sticky and lock status seperate from topic icons? */
   $settings['seperate_sticky_lock'] = true;


Replace it with:


   /* Show sticky and lock status seperate from topic icons? */
   $settings['seperate_sticky_lock'] = true;

   /* Call to Theme String for languages  */
   if (loadlanguage('ThemeStrings') == false)
      loadLanguage('ThemeStrings', 'english');





In 2.0 RC1 and onwards, a new way of including ThemeStrings.language.php would be to set $settings['require_theme_strings'] to true in index.template.php.  It would look something like this:

/* Set the following variable to true if this theme requires the optional theme strings file to be loaded. */
$settings['require_theme_strings'] = false;


by default, and when false is changed to true, it'll start to load ThemeStrings alongside the other language files SMF needs to display the page.

An English version of this file can be found attached.
Eren "forsakenlad" Yaşarkurt
SMF Friend & Former Team Member

Antechinus

I have a question.  :D  You knew it had to happen.

Anyway I was using this code, which seems to work just fine:

/* Call to Theme String for languages  */
loadLanguage('ThemeStrings');


Is the code you posted better in some way or doesn't it matter?  If it is better I'll use it in future.

Deaks

The one we have included will fall back to the english version (as this will always be in a new theme) so say you are using Hungarian and there is no hungarian ThemeStrings the english version will show.  Its just an updated version of the code you will find in many older themes
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

rapidvectorseo

English version does not required code.

Deaks

We advise even english  speaking authors add this aswell it helps with making trhe theme suitable for all languages
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Orangine

I'm trying to separate theme strings to make it easier to add more languages in future, but I'm stuck here. It seems this method doesn't work anymore. Can you help me and point me to the right direction? Many thanks!

Gary

The second method Eren pointed you to of setting $settings['require_theme_strings'] in index.template.php to true, will cover you. It's not there by default, so you need to add it into the template_init function yourself.
Gary M. Gadsdon
Do NOT PM me unless I say so
War of the Simpsons
Bongo Comics Fan Forum
Youtube Let's Plays

^ YT is changing monetisation policy, help reach 1000 sub threshold.

Orangine

#7
I've added that, created ThemeStrings.english.php and ThemeStrings.english-utf8.php then I've put them into my theme's folder, but still the strings are not showing up. What I'm doing wrong?

edit:
Ok, got it. ThemeStrings.english.php has to be put inside 'languages' folder, works ok now.

Deaks

always the simple things that fix the issue :)
~~~~
Former SMF Project Manager
Former SMF Customizer

"For as lang as hunner o us is in life, in nae wey
will we thole the Soothron tae owergang us. In truth it isna for glory, or wealth, or
honours that we fecht, but for freedom alane, that nae honest cheil gies up but wi life
itsel."

Orangine


Advertisement: