How does AnQiCMS implement the switch of multilingual content and correct display?

Calendar 👁️ 82

In order to meet the needs of global content operations, allowing your website to support the switching and correct display of multi-language content is a key step to expand the market and improve user experience.AnQiCMS (AnQiCMS) is a feature-rich content management system that provides an intuitive and powerful multilingual solution to help you easily meet this challenge.Next, we will discuss in detail how to achieve this goal in AnQiCMS.

The core concept of AnQiCMS multilingual support

AnQiCMS was designed from the outset to consider the need for multilingual content.The core feature list clearly points out that it supports the switching and display of multilingual content, meets the needs of global content promotion, and aims to allow content to directly face users of different languages, helping enterprises to expand their international market.System language package/Multi-site managementas well asTranslation tag at the template levelCombined in a way to ensure the internationalization of the website interface and the localization of content

1. Multilingual configuration of the system backend and built-in information

First, AnQiCMS provides multilingual support for its own interface. In the website background,Global SettingsIn it, you can find the 'default language package' option.Currently, the system is built with Chinese and English languages.After selecting the corresponding language package, the backend management interface and some built-in text generated by the system (such as certain prompt information, system messages, etc.) will be displayed according to the language you select.

It is noteworthy that the "default language pack" here is mainly for the system UI and built-in, non-user customized content.It will not automatically translate your articles, product descriptions, category names, and other core business content.For these core contents published and managed by users, a more flexible strategy needs to be adopted.

2. Multilingual implementation of core content: multi-site management

For articles, products, single-page websites, and other core content, AnQiCMS recommends using its powerfulMulti-site managementTo implement the distinction and management of multilingual versions. This means you can create an independent sub-site for each target language (such as:en.yourdomain.comrepresenting the English site,fr.yourdomain.comRepresents the French site), or through subdirectories (such as: yourdomain.com/en//yourdomain.com/fr/) to distinguish.

Under multi-site management, each site can be independently configured, have its own database or data prefix (in the case of Docker deployment, a shared database can be reused), and can bind to an independent domain or directory.Thus, you can create and manage the content of the language version under each language site, ensuring the accuracy and professionalism of the content.For example, you can create a Chinese version of the same article on the Chinese site and an English version on the English site.Although this requires you to manually create and maintain content for each language, it ensures the quality and localization of the content, and avoids the inaccuracy that machine translation may bring.

3. Translation at the template level and language switching

To enable the front-end website to display content and interface elements correctly according to the user's selected language, AnQiCMS provides convenient translation tags and multi-language site list tags in template design.

Translation of static text:{% tr %}Tag

For some fixed texts in website templates, such as navigation menu items, button text, copyright statements, etc., you can use AnQiCMS's{% tr %}Manage translation tags. This requires you to create a folder namedlocalesin the template directory, and create subfolders anddefault.ymlfiles for each language. For example:

./locales
├── en-us
│   └── default.yml  (内容如:yourLocation: "Your Location")
└── zh-cn
    └── default.yml  (内容如:yourLocation: "您的位置")

Then, in your template, you can use{% tr "yourLocation" %}this method to call the translation. When the user switches languages, the system will automatically use the correspondingdefault.ymlRead and display the translated text in the file, allowing the website interface to seamlessly switch to the target language.

Language switcher and Hreflang tags:{% languages %}Tag

To provide users with convenient language switching functionality, you can use{% languages websites %}Label. This label can retrieve the list of all configured multilingual sites and provides information such as each site's language name, link, and icon. By traversing thiswebsitesVariable, you can easily build a language switch menu.

Here is an example of code to create a language switcher.

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

This code snippet will generate a list of link, each link points to a site in a different language.item.LinkIt will automatically direct to the homepage of the corresponding language site.

To better support search engine optimization (SEO), especially to help search engines understand the structure of your multilingual content, it is recommended to place on the page's<head>the tag withhreflangProperty.{% languages %}The tag can also help you achieve this:

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

This helps search engines correctly match different language versions of content to the target audience, avoid duplicate content issues, and enhance the search visibility in the international market.

Summary

By using AnQiCMS's system-level language package, multi-site management features, and flexible template translation tags, you can build a fully functional, user-friendly multilingual website. The core idea is to use multi-site management to isolate and publish different language versions of content, ensuring the quality of content localization; utilizing{% tr %}Label to translate static text in the template to maintain interface consistency; finally, through{% languages %}Label building language switching function and optimizing SEO, helping your website to succeed globally.


Frequently Asked Questions (FAQ)

  1. Does the AnQiCMS 'default language package' setting automatically translate the content of the articles I publish?No, the default language package is mainly used to translate the AnQiCMS backend management interface and some built-in system information on the front end.The core content you publish, such as articles and product descriptions, needs to be manually created and managed in different language versions, usually through the multi-site management feature to achieve content isolation.

  2. Can I post articles in multiple languages on the same site and switch through a dropdown menu?AnQiCMS is a core multilingual content management solution based on "multi-site management".This means you will create a separate site for each language to store the corresponding language content.It is technically possible to implement multilingual content switching within a single site through secondary development, but this may increase the complexity of content management and may not comply with the default design philosophy of AnQiCMS.Recommend using multi-site management to ensure clear and efficient content management.

  3. What ishreflangWhat is the role of tags in a multilingual website? hreflangTags are HTML attributes used to tell search engines that a web page is a specific language or regional version of content.It is very important in multilingual websites, it can help search engines display the most relevant web version to users who use specific languages or are located in specific regions, thus avoiding duplicate content issues, improving SEO effects, and enhancing user experience.{% languages %}These labels are automatically generated, simplifying the configuration.

Related articles

How to display custom fields defined in the AnQiCMS content model on the front end?

AnQiCMS's flexible content model is one of its core advantages, allowing us to define unique fields for different types of content according to actual business needs, thereby freeing ourselves from the limitations of traditional CMS fixed content structure.When we create these custom fields, the next critical step is to display them elegantly on the website frontend.This article will introduce you in detail how to define custom fields in the AnQiCMS backend, as well as how to flexibly call and display this information in the frontend template, making your website content more personalized and practical.### One

2025-11-08

How to customize the display template for articles, products, and single pages in AnQiCMS?

In AnQiCMS, customizing the display templates for articles, products, and single pages is a very flexible and powerful feature that allows you to create exclusive display styles for different types of content according to the unique needs of your website.By carefully designed templates, not only can the user experience be improved, but also the focus of the content can be better highlighted, achieving the unity of brand style.AnQiCMS uses a template engine syntax similar to Django, which means if you are familiar with this concise and intuitive syntax, you can quickly get started.

2025-11-08

How to use the `archiveParams` tag to retrieve and display the content of the custom parameter fields of the document?

In daily website operations, we often encounter the need that standardized content fields can no longer meet the diversified display of information.For example, a product detail page may need to display unique attributes such as "model", "material", "warranty period", etc., while a regular article may need additional notes such as "source of the article", "estimated reading time", etc.

2025-11-08

How to dynamically generate and display SEO titles, keywords, and descriptions for `tdk` tags on different pages?

In website operation, the title (Title), keywords (Keywords), and description (Description), known as TDK, are indispensable core elements of search engine optimization (SEO).They not only directly affect the display of the website on the search engine results page (SERP), but also determine whether users click to enter your website.

2025-11-08

How to dynamically display the 'recommended properties' (such as headlines, recommendations) of articles or products on a page?

When operating website content, we often need to make special recommendations for certain articles or products, such as 'headline', 'hot', or 'recommended', etc., in order to display them more prominently on the page and guide users' attention.AnQiCMS provides a very flexible "recommendation attribute" feature, allowing you to easily achieve this.Let's take a look together at how to set these properties in AnQiCMS and dynamically display them on your website.

2025-11-08

What thumbnail processing methods does AnQiCMS support, and how to set them to optimize the display effect?

In website operation, image content plays a crucial role, especially exquisite thumbnails can quickly attract users' attention, enhance the visual beauty of the page, and improve the click-through rate.AnQiCMS (AnQiCMS) offers flexible and diverse functions in image processing, especially for thumbnail generation and optimization, aiming to help websites achieve **display effects.We will delve into the thumbnail processing methods supported by AnQiCMS, as well as how to make your website images come to life through reasonable settings.### The core mechanism of AnQiCMS thumbnail processing First

2025-11-08

How to set a default thumbnail to automatically display when there is no image in the article?

In content operation, images play a crucial role.They can not only catch the visitor's eye, enhance reading interest, but also effectively convey information and enhance the brand image.However, when updating articles daily, we may occasionally forget to upload thumbnails, or some content is not suitable for pictures.This is when a blank page appears on the article list or detail page, which seems unprofessional and affects user experience.Fortunately, AnQiCMS (AnQiCMS) has considered this point and provided a very practical feature: setting a default thumbnail.With it, even if the article does not have a picture

2025-11-08

How to display the viewing volume of articles or products on the frontend page?

Bring content to life: easily display the number of views for articles or products on the Anqi CMS front-end page In website operations, the number of views for articles or products is often an important indicator of how popular the content is.It not only provides visitors with an intuitive reference, forming a "social identity" effect, guiding them to discover popular content, but also helps operators quickly identify high-value content.AnQi CMS is an efficient content management system that fully considers the actual needs of users, making it very simple and intuitive to display the number of views of articles or products on the front-end page.

2025-11-08