Difference between revisions of "Using Language Keys"

From Cheetah Documentation Wiki
Jump to navigation Jump to search
(Created page with "<syntaxhighlight lang="python" line='line'> def quick_sort(arr): less = [] pivot_list = [] more = [] if len(arr) <= 1: return arr else: pass </syntaxhighlight>")
Tag: visualeditor-switched
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<syntaxhighlight lang="python" line='line'>
+
<div class="markdown-body">
def quick_sort(arr):
+
 
less = []
+
Cheetah features a powerful language system that makes it possible to translate almost every part of the site. This is done with what are called Language Keys.
pivot_list = []
+
 
more = []
+
'''What's a Language Key?'''
if len(arr) <= 1:
+
 
return arr
+
A Language Key is a kind of placeholder text, which allows a button, page, title, etc. to be shown in different languages based on the user's language settings. Most Language Keys look like this:
else:
+
 
pass
+
<code>_exampleLanguageKey</code>
</syntaxhighlight>
+
 
 +
When Cheetah sees this text, it checks the database for matching keys. When it finds one, it looks up the value for that user's language. So for example, User A will see the text on the site as "Example Language Key", while User B will see "Языковой ключ, для примера". Almost all non-user-added text in Cheetah uses Language Keys.
 +
 
 +
'''Managing Language Keys'''
 +
 
 +
Language Keys are managed with the rest of the language system, from the Admin Panel => Settings => Languages. It looks like this:
 +
 
 +
[[File:687474703a2f2f692e696d6775722e636f6d2f4c6d4d6772724e2e706e67.png|800px]]
 +
 
 +
For this tutorial, we'll focus on the first page ("Keys"). It only has a search box, which allows us to search for existing Language Keys. To search, enter the key or display text you want to edit, and then tick the Apply box. You should see some results if there were matches. Let's search for the "_copyright" key to edit the footer's copyright text:
 +
 
 +
[[File:687474703a2f2f692e696d6775722e636f6d2f6e72304a3336372e706e67.png|800px]]
 +
 
 +
You can also search for the display text if you don't know the actual Language Key:
 +
 
 +
[[File:687474703a2f2f692e696d6775722e636f6d2f376277664c5a582e706e67.png|800px]]
 +
 
 +
To preview or edit the results, click the Edit link next to the Language Key. This will open an edit window with the display text for each installed language:
 +
 
 +
[[File:687474703a2f2f692e696d6775722e636f6d2f56534c685038632e706e67.png|800px]]
 +
 
 +
To edit, change the String Text value for your language and click the Save button. Changes should take effect almost immediately. If not, try clearing Cheetah's cache from the Admin Panel => Tools => Cache, and click the Clear All link.
 +
 
 +
 
 +
</div>

Latest revision as of 11:40, 14 October 2021

Cheetah features a powerful language system that makes it possible to translate almost every part of the site. This is done with what are called Language Keys.

What's a Language Key?

A Language Key is a kind of placeholder text, which allows a button, page, title, etc. to be shown in different languages based on the user's language settings. Most Language Keys look like this:

_exampleLanguageKey

When Cheetah sees this text, it checks the database for matching keys. When it finds one, it looks up the value for that user's language. So for example, User A will see the text on the site as "Example Language Key", while User B will see "Языковой ключ, для примера". Almost all non-user-added text in Cheetah uses Language Keys.

Managing Language Keys

Language Keys are managed with the rest of the language system, from the Admin Panel => Settings => Languages. It looks like this:

687474703a2f2f692e696d6775722e636f6d2f4c6d4d6772724e2e706e67.png

For this tutorial, we'll focus on the first page ("Keys"). It only has a search box, which allows us to search for existing Language Keys. To search, enter the key or display text you want to edit, and then tick the Apply box. You should see some results if there were matches. Let's search for the "_copyright" key to edit the footer's copyright text:

687474703a2f2f692e696d6775722e636f6d2f6e72304a3336372e706e67.png

You can also search for the display text if you don't know the actual Language Key:

687474703a2f2f692e696d6775722e636f6d2f376277664c5a582e706e67.png

To preview or edit the results, click the Edit link next to the Language Key. This will open an edit window with the display text for each installed language:

687474703a2f2f692e696d6775722e636f6d2f56534c685038632e706e67.png

To edit, change the String Text value for your language and click the Save button. Changes should take effect almost immediately. If not, try clearing Cheetah's cache from the Admin Panel => Tools => Cache, and click the Clear All link.