Using Language Keys

From Cheetah Documentation Wiki
Jump to navigation Jump to search

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.