Difference between revisions of "Great! So how do I use language strings"

From Online Manual

Jump to: navigation, search
m (2 revisions: Importing from local.)
 
(6 intermediate revisions by 4 users not shown)
Line 1: Line 1:
The fact that SMF uses language strings is all well and good, but what does that mean to you? If you use english in your theme, will that get automatically translated for you? Heh, we wish. No, you have to specifically use it in your [[Theme] - this means no english phrases :/. To have strings also available in languages like German or Thai, you will need the $txt variable. This is a lot like $context, except that it stores only a list of language strings available. To use out above example, you might use something like $txt['sendtopic_to_friend']. In your template, it would look a bit like this:
+
The fact that SMF uses language strings is all well and good, but what does that mean to you? If you use english in your theme, will that get automatically translated for you? Heh, we wish. No, you have to specifically use it in your [[Theme] - this means no English phrases :/. To have strings also available in languages like German or Thai, you will need the $txt variable. This is a lot like $context, except that it stores only a list of language strings available. To use out above example, you might use something like $txt['sendtopic_to_friend']. In your template, it would look a bit like this:
 +
{{code|<nowiki><b>', $txt['sendtopic_to_friend'], '<b></nowiki>}}
 +
As you can see, the identifier goes inside the brackets after $txt, surrounded by single quotes - just like contextual data Wink. You have to use the ', ... , ' format to separate the string from regular text, though, as well.
  
<div class="codeheader">: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation"></a></div><code>&lt;b&gt;&#039;, $txt[&#039;sendtopic_to_friend&#039;], &#039;&lt;b&gt;</code>
+
[[Category:Developing SMF]]
As you can see, the identifier goes inside the brackets after $txt, surrounded by single quotes - just like contextual data Wink. You have to use the &#039;, ... , &#039; format to separate the string from regular text, though, as well.
+
[[Category:Customizing SMF]]

Latest revision as of 06:41, 15 August 2013

The fact that SMF uses language strings is all well and good, but what does that mean to you? If you use english in your theme, will that get automatically translated for you? Heh, we wish. No, you have to specifically use it in your [[Theme] - this means no English phrases :/. To have strings also available in languages like German or Thai, you will need the $txt variable. This is a lot like $context, except that it stores only a list of language strings available. To use out above example, you might use something like $txt['sendtopic_to_friend']. In your template, it would look a bit like this:

<b>', $txt['sendtopic_to_friend'], '<b>

As you can see, the identifier goes inside the brackets after $txt, surrounded by single quotes - just like contextual data Wink. You have to use the ', ... , ' format to separate the string from regular text, though, as well.