Using Language Keys

From Cheetah Documentation Wiki
Revision as of 11:30, 14 October 2021 by Admin (talk | contribs)
Jump to navigation Jump to search

Dolphin 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 Dolphin 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 Dolphin 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:Https://camo.githubusercontent.com/b76fc1a95da8b3eee186ca47071cb9430d7f90e97cf8bfbf1a0c25345babd8c8/687474703a2f2f692e696d6775722e636f6d2f4c6d4d6772724e2e706e67

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:Https://camo.githubusercontent.com/c5e6e57c41440c201cc5fcd5758d5aa0f332110c0ce6dcf78b0ace03ce00d3c5/687474703a2f2f692e696d6775722e636f6d2f6e72304a3336372e706e67

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

File:Https://camo.githubusercontent.com/11b4f7c3de97b7cc5d012627546dfb9d341947ad3dd13469afdb9e97e9165912/687474703a2f2f692e696d6775722e636f6d2f376277664c5a582e706e67

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:Https://camo.githubusercontent.com/c08dbf2d30963435044f1b55747924cb24a25ef26255991ddc7c62381820d9cd/687474703a2f2f692e696d6775722e636f6d2f56534c685038632e706e67

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 Dolphin's cache from the Admin Panel => Tools => Cache, and click the Clear All link.