How does AnQi CMS support the publishing of multilingual content and front-end switching display?

In today's globalized business environment, whether a website can support multilingual content publishing and switching has become an important standard for measuring its internationalization capabilities.AnQiCMS (AnQiCMS) is an efficient content management system that fully considers this need, providing users with a flexible and practical multilingual content solution.

To understand how AnQiCMS supports multilingual, we can look at two main aspects: one is the management and publication of core content such as actual articles, products, and pages; the other is the translation and switching of fixed text in website templates (such as navigation names, button text).

The publication and management of multilingual content: multi-site strategy

The core mechanism of AnQiCMS handling multilingual core content is its powerfulMulti-site managementFunction. When you need to provide independent content for users of different languages, the most direct and efficient method is to use this feature.

In particular, you can create a separate site for each target language. For example, if your business needs to support Chinese, English, and Japanese, you can set up three sites:

  • Main site (for examplewww.yourdomain.com, for Chinese content
  • English site (for exampleen.yourdomain.com)
  • Japanese site (for examplejp.yourdomain.com)

Each site has its own independent database, content, and template configuration, but can share the same AnQiCMS program.This means that the content of each language will be independently published and managed on its dedicated site, without interference, ensuring the accuracy and professionalism of the content.When operating in the background, you can log in to the corresponding language site backend and add, edit, and publish articles, products, or single pages for that language, just like managing a single site.The advantage of this method lies in its ability to maintain high flexibility in structure, SEO optimization, and operational strategy for content in different languages, avoiding confusion that may arise from managing multiple languages in a single content library.

It is worth noting that the "default language package" option in the global feature settings mainly affects the language of the backend management interface and some built-in system prompts.It will not automatically translate the core content of your website, such as articles, products, etc.Therefore, for the core content of different languages, we still need to maintain separate sites.

Front-end multi-language switch and display

On the website front-end, allowing visitors to easily switch languages is a key factor in improving user experience. AnQiCMS provides a very practical template tag for this:{% languages %}.

This tag will automatically retrieve all the multilingual site information you have configured in the AnQiCMS backend, including the site's language name, language code, link address, and even the language emoticons or icons that can be used for display.You can use this tag to build a dynamic language switcher in website templates, such as in the header or footer.

Here is a commonly used code example showing how to generate a language switch link:

{%- languages websites %}
{%- if websites %}
<div>
    <span>切换语言:</span>
    {%- for item in websites %}
    <a href="{{item.Link}}">
        {%- if item.LanguageIcon %}
        <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" />
        {%- else %}
        {{item.LanguageEmoji}}
        {% endif %}
        {{item.LanguageName}}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endLanguages %}

This code will iterate over all configured multilingual sites and generate a toggle option for each site that includes links and language names (or icons, emojis).Clicking on this will take you to the website in your language.

In addition, to better serve international users and optimize search engine rankings, configure correctlyhreflangtags are crucial.hreflangThe tag can tell search engines that a specific page is an alternative version for pages in other languages or regions, thus avoiding duplicate content issues and improving international SEO effects. You can also take advantage of{% languages %}Tags to dynamically generate these importanthreflangTags, usually placed in HTML's<head>Area:

{%- languages websites %}
{%- for item in websites %}
<link rel="alternate" href="{{item.Link}}" hreflang="{{item.Language}}">
{%- endfor %}
{%- endLanguages %}

Translation of fixed text in the{% tr %}Tag

In addition to the core content, there are many fixed texts in the website template, such as the "Home" page, "Contact Us", "Submit" button, copyright information prompt, and so on.This also needs to be translated according to the language set by the website to provide a complete localization experience.AnQiCMS provided this for{% tr %}(translate) tag.

Use{% tr %}Label needs some simple configuration:

  1. Create a folder named under your template root directory:locales.
  2. InlocalesInside the folder, create a subdirectory for each target language, such as:en-us(English),zh-cn(Simplified Chinese),ja(Japanese) etc.
  3. Create one or more in each language subdirectory,.ymlfile (for exampledefault.yml), for storing the translation key-value pairs.

For example,zh-cn/default.ymlFiles may include:

"yourLocation": "您的位置"
"homePage": "首页"
"contactUs": "联系我们"

Corresponding toen-us/default.ymlThe file may contain:

"yourLocation": "Your Location"
"homePage": "Home"
"contactUs": "Contact Us"

Where you need to use these translated texts in the template, you just need to use{% tr "键名" %}format. For example:

<a href="/">{% tr "homePage" %}</a>
<p>{% tr "contactUs" %}</p>

When the website visitor switches language, AnQiCMS will automatically load the corresponding language based on the current site settings,.ymlRead and display the corresponding translation text in the file, ensuring that the text information on the front-end page is fully adapted to the target language.

Summary

AnQiCMS combines flexibility withMulti-site managementStrategy to carry the core content of different languages, utilizing{% languages %}TagAchieve front-end language switching and SEO optimization, and leverage{% tr %}TagManage the translation of static text in the template. This set of comprehensive and well-defined mechanisms provides solid support for enterprises and content operators to build efficient, professional global multi-language websites, facilitating borderless content dissemination.


Frequently Asked Questions (FAQ)

How to create and manage content in different languages for AnQiCMS?You need to use the "Multi-site Management" feature of AnQiCMS. Create an independent site for each target language (for exampleen.yourdomain.com/fr.yourdomain.comThen, log in to the backend of each site independently to publish and manage articles, products, single pages, and other core content in that language.This ensures that the content is independent between different language versions, making it easy for fine-grained operations and SEO.

2. Will changing the 'Default Language Pack' in the background translate my website content?I don't know. The 'Default Language Pack' in the global function settings mainly affects the display language of the AnQiCMS backend management interface, as well as some built-in system prompts and date formats.It does not automatically translate the core content (such as article titles, body text, product descriptions, etc.) that has been published on your website. This content needs to be manually entered or translated on the corresponding language site before it can be published.

How to translate fixed button or navigation text such as 'Submit' or 'Home' in website templates?For text that is fixed in the template and does not change with the article content, you can use AnQiCMS's{% tr "键名" %}translation tags. First, create the template directory.localesFolder, and create subdirectories for each language (such asen-us), and then create.ymlfiles (such asdefault.yml), and write key-value pairs into them. For example,"homePage": "Home". Then, use them in the template.{% tr "homePage" %}Call it, the system will automatically display the correct translation based on the current website's language settings.