How to configure AnQiCMS multilingual support to switch and display content correctly?

Calendar 👁️ 61

AnQiCMS provides powerful multilingual support features, helping us easily promote our website content to global users.However, in order to switch and display multilingual content correctly, we need to understand the design approach of AnQiCMS in this aspect and configure and manage it through several key steps.It mainly achieves independent content for different language versions by combining 'Multi-site management', and at the same time provides 'Default language package' and 'Translation tags' to handle the static text in the system built-in text and templates.

Understanding the multilingual mechanism of AnQiCMS

Firstly, we need to clarify the definition and handling of "multilingual" by AnQiCMS. ForCore content published by the user(such as articles, products, single pages, etc.), AnQiCMS tends to adopt a multi-site mode.This means that if you want to provide an English translation version of your Chinese article, the usual practice is to create or translate this article on a dedicated English site.The benefits of this design lie in the fact that each language version of the website can have its own domain name, its own template style, its own content, and SEO strategy, providing the greatest flexibility and manageability.

At the same time, AnQiCMS also provides forsystem built-in text(such as background interface hints, default messages) andhard-coded static text in templates(such as the translation mechanism for navigation menu items, footer copyright information such as "Contact Us", etc.)This allows even a single website to switch the display language of these auxiliary texts while keeping the core content unchanged.

In summary, the multilingual support of AnQiCMS can be decomposed into the following main configuration stages:

1. Plan and build a multilingual site architecture

As mentioned earlier, for different language versions of the content subject (for example, a Chinese product introduction and the corresponding English product introduction), AnQiCMS most recommends setting up an independent site for each language.

Imagine you have a main siteyourcompany.comIf you are operating Chinese content, you may need to create a new siteen.yourcompany.comCarry your English content. In the "Multi-site Management" feature of AnQiCMS, you can easily add and configure these new sites.Each site will have an independent database, file storage, and backend management entry, but they are all efficiently managed by the same AnQiCMS instance.

When creating a new site, you need to specify a unique domain name or subdomain for each language site and configure the database and back-end administrator account for it.Later, you can independently publish and manage all articles, products, pages, and other content under each language site's backend.

2. Configure the default system language package

This step is mainly to manage the AnQiCMS backend interface and some text display languages generated or built-in on the website frontend.

In the AnQiCMS backend, go to the page under "Backend Settings" and "Global Function Settings", where you will see an option for the "Default Language Pack".Here is built-in Chinese and English and other languages for selection. After you have selected and saved a specific language package for a site, the background management interface of the site and some system default displayed text (such as, if your template directly calls the system built-in "Previous", "Next" navigation text) will be displayed according to the selected language.

It is important to remember,This setting will not automatically translate the specific content of articles, products, or pages you publish in the background. It mainly affects the language display at the system level.

3. Translation of static text in the template

Many website templates contain some fixed and unchangeable text, such as "Home", "About Us", "Contact Us", "Privacy Policy", etc. This text is usually not dynamically generated by the backend content management system, but is written directly in the template file (.htmlIn the file. In order for these static texts to also be switched according to the current site's language settings, AnQiCMS has introduced translation tags andlocalesDirectory.

You need to create one in your template folderlocalesdirectory. Under this directory, create a subfolder for each target language, the folder name should correspond to the language code (for examplezh-cnrepresenting Simplified Chinese,en-usRepresents American English,jaRepresents Japanese and others.). Create one in each language subfolderdefault.ymlfile.

For example, for a website that supports Chinese-English bilingualism:

  • /template/您的模板名/locales/zh-cn/default.yml

    "yourLocation": "您的位置"
    "contactUs": "联系我们"
    
  • /template/您的模板名/locales/en-us/default.yml

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

You can use it in your template file.{% tr "键名" %}Label to reference these translation texts. For example, to<div>联系我们</div>changed to<div>{% tr "contactUs" %}</div>. When accessing a site in the corresponding language, the system will automatically retrieve from the respectivedefault.ymlLoad and display the correct translation text in the file.

4. Implement the front-end language switching function.

In order for users to switch between different language sites, you need to provide a language switcher on the website frontend. AnQiCMS provides{% languages websites %}Tag to help you achieve this function.

This tag will retrieve the list of sites configured for multilingual in multi-site management.You can iterate through this list in the template to generate a link for each language site, and users can click these links to jump to the corresponding language website.

For example, you can use it in your template file (usually the common part of the header or footer):

{% 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}} <!-- 如果没有图标,可以显示语言对应的 Emoji 符号 -->
        {% endif %}
        {{item.LanguageName}}
    </a>
    {% endfor %}
</div>
{% endif %}
{% endlanguages %}

Don't forget to add language switch links for SEO optimization.hreflangTags. This helps search engines understand that your website content provides different language or regional versions, avoids duplicate content issues, and ensures that users can access the page most suitable for their language and region.You can<head>Add similar code to the region.

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

Hereitem.LinkIt will point to your various language site URLs.item.LanguageIt corresponds to the language code (for exampleen-us,zh-cn)

Summary

The multi-language support strategy of AnQiCMS is an important manifestation of its enterprise-level positioning.It isolates and manages content for different language versions through flexible multi-site management, and provides a meticulous system language package and template translation mechanism to handle auxiliary text. Combining{% languages %}Tags to implement front-end switching andhreflangTags for SEO optimization, you can build a powerful, globally user-friendly multilingual website.


Frequently Asked Questions (FAQ)

1. Can AnQiCMS automatically translate my article or product content?I don't know. AnQiCMS uses a 'content isolation' multi-site management model to handle the core content of different language versions.This means that you need to maintain a separate site for each language and create, upload, or translate your articles, product descriptions, and other content on these sites.The system will not automatically translate content.

2. Can I run only one website but want some fixed text (such as footer copyright statements, navigation links) to support language switching?Can be. In this case, you can not use the multi-site feature to distinguish the main content, but you can still take advantage of the two features of 'configuring the system default language package' and 'translation of static text in templates'.You can configure in your templatelocalesTable of contents and{% tr %}Label to translate static text. As for language switching, you can use{% languages websites %}Create a link pointing to a different language path for the tag, or manually control the link logic, but please note that only the static text in the template and the system built-in text are switched at this time, while the content of the articles you publish in the background will remain in the original language unchanged.

How to determine which type of page is displayed in the template

Related articles

How to implement unified management and display of multi-site content on the front end in AnQiCMS?

Manage and display the content of multiple websites in AnQiCMS, which is a common need for many operators, especially when you need to manage multiple brand sites, product sub-sites, or provide customized content for users in different regions or languages.AnQiCMS was designed with this in mind from the outset, providing a flexible and efficient solution that allows you to easily manage the content of multiple front-end sites from a single backend.### Backend unified management: One system, multiple sites One of the core strengths of AnQiCMS is that it supports multi-site management

2025-11-07

How can AnQiCMS flexibly customize the content model to meet diverse display needs?

## Harness AnQiCMS: Flexible Content Model Customization, Unlock the Potential of Diverse Display Methods In today's digital age, websites are no longer platforms for displaying a single content form.Whether it is a corporate website, e-commerce product catalog, industry information station, or personal blog or online education platform, the core content is often very different, with unique structures and display requirements.Traditional CMS systems often rigidly limit content to fixed frameworks such as "articles" or "products", which undoubtedly presents many challenges for operators who pursue personalization and professionalism.

2025-11-07

What are other practical application scenarios of the filter in AnQiCMS templates, besides direct display or assignment?

The template language of AnQiCMS (AnQiCMS) provides rich features, not limited to direct data display or simple assignment.Among them, filters play an important role, which can transform, format and process variable values in templates to achieve more flexible and dynamic content display.When we delve deeper into the practical scenarios of these filters, we will find that they greatly enhance the expression capabilities and development efficiency of templates.

2025-11-07

In the multilingual AnQiCMS site, can the `contain` filter correctly judge different language keywords?

In the AnQiCMS multilingual site, can the `contain` filter correctly judge keywords in different languages?AnQiCMS as a feature-rich enterprise-level content management system, with its powerful multilingual support capabilities, enables content operators to easily reach a global audience.However, in the actual content management and display, we often need to perform keyword detection or filtering.At this point, a key question arises: Can the `contain` filter in the template accurately identify keywords when faced with content in different languages?

2025-11-07

How to use AnQiCMS pseudo static and 301 redirect function to optimize URL structure to improve SEO display effect?

In website operation, the structure of URL has a significant impact on search engine optimization (SEO) effectiveness.A clear, concise, and descriptive URL that can improve user experience and help search engines better understand page content, thereby improving crawling efficiency and ranking.AnQiCMS is a powerful content management system that provides comprehensive pseudo-static and 301 redirect functions, helping us create an ideal URL structure.### Understanding SEO-friendly URLs and their importance Imagine that

2025-11-07

How does AnQiCMS's scheduled publishing function ensure that content is displayed accurately on the website as planned?

In today's fast-paced digital world, the timing of publishing website content is often as important as the content itself.In order to coordinate with market activities, seize hot news, or simply to maintain the regularity of content publication, the ability to accurately control the timing of content going live is crucial.AnQiCMS (AnQiCMS) deeply understands this, and its built-in scheduled publishing function is designed to meet this core requirement, ensuring that your website content is displayed accurately and as planned to visitors.### Say goodbye to manual operation

2025-11-07

How to use AnQiCMS template tags to retrieve and display the system configuration information of the website?

In Anqi CMS, the system configuration information of the website is the foundation for its operation, including the website name, Logo, filing number, address, and other core data.This information is usually needed to be dynamically displayed on various pages of the website (such as the header, footer, contact us page, etc.) to maintain consistency.To facilitate template developers and content operators to efficiently manage and display this information, AnQiCMS provides a simple and powerful template tag that allows you to flexibly obtain and display the system configuration of the website.Where is the system setting of AnQi CMS? First

2025-11-07

How to call and display the title, content, and related fields of a document on the AnQiCMS article detail page?

In AnQiCMS, the content detail page is the key area where you display core information and attract readers.Effectively call and display the title, content, and various related fields of the document, which can greatly enhance user experience and the richness of page information.The powerful template engine of AnQiCMS provides an intuitive and flexible way to achieve these goals.## Understanding AnQiCMS Template Syntax AnQiCMS's template system uses syntax similar to Django template engine, it mainly operates data and logic through two forms: * **Double Curly Braces

2025-11-07