Advertisement:

Author Topic: Text Strings in Themes  (Read 18769 times)

Offline Eren Yaşarkurt

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 7,134
  • Gender: Male
  • aka forsakenlad
    • erenyasarkurt on Facebook
    • erenyasarkurt on LinkedIn
    • @erenyasarkurt on Twitter
    • yekolay
Text Strings in Themes
« on: September 12, 2008, 05:24:04 PM »
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:

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

Replace it with:

Code: [Select]
   /* 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:

Code: [Select]
/* 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.
« Last Edit: March 20, 2009, 06:51:28 PM by Gazmanafc »
Eren "forsakenlad" Yaşarkurt
SMF Friend & Former Team Member

yemek siparişi - order your food quick and easy

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 24,136
  • Master of BBC Abuse
Re: Theme Strings in Themes
« Reply #1 on: September 14, 2008, 05:34:50 AM »
I have a question.  :D  You knew it had to happen.

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

Code: [Select]
/* 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.

Offline BryanD

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,023
  • Gender: Male
    • BryanRunicDeakin on Facebook
    • @bryandeakin on Twitter
    • Bryan Deakin dot Com
Re: Theme Strings in Themes
« Reply #2 on: September 14, 2008, 05:41:51 AM »
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

Offline rapidvectorseo

  • Newbie
  • *
  • Posts: 1
Re: Theme Strings in Themes
« Reply #3 on: September 29, 2008, 07:26:16 AM »
English version does not required code.

Offline BryanD

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,023
  • Gender: Male
    • BryanRunicDeakin on Facebook
    • @bryandeakin on Twitter
    • Bryan Deakin dot Com
Re: Theme Strings in Themes
« Reply #4 on: September 29, 2008, 08:06:39 AM »
We advise even english  speaking authors add this aswell it helps with making trhe theme suitable for all languages

Offline Orangine

  • Full Member
  • ***
  • Posts: 661
  • Gender: Female
Re: Text Strings in Themes
« Reply #5 on: July 14, 2012, 03:25:20 PM »
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!

Offline Gary

  • Lead Customizer
  • SMF Super Hero
  • *
  • Posts: 17,320
  • Gender: Male
  • So this is the luck of the draw...
    • Gazmanafc on Facebook
    • garygadsdon on LinkedIn
    • @Gazmanafc on Twitter
    • The Bongo Comics Fan Forum
Re: Text Strings in Themes
« Reply #6 on: July 14, 2012, 04:34:44 PM »
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.

Offline Orangine

  • Full Member
  • ***
  • Posts: 661
  • Gender: Female
Re: Text Strings in Themes
« Reply #7 on: July 14, 2012, 04:47:13 PM »
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.
« Last Edit: July 14, 2012, 05:10:46 PM by Orangine »

Offline BryanD

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,023
  • Gender: Male
    • BryanRunicDeakin on Facebook
    • @bryandeakin on Twitter
    • Bryan Deakin dot Com
Re: Text Strings in Themes
« Reply #8 on: July 15, 2012, 01:50:30 AM »
always the simple things that fix the issue :)

Offline Orangine

  • Full Member
  • ***
  • Posts: 661
  • Gender: Female
Re: Text Strings in Themes
« Reply #9 on: July 15, 2012, 09:34:52 AM »
I have added this info to Creating and Understanding Themes in wiki.