How to set up multilingual support in AnQiCMS and provide language switching options on the front-end page?

Calendar 👁️ 67

Today, with the deepening of globalization, multilingual support for websites is no longer an option, but a key to enterprises expanding into international markets and enhancing user experience.AnQiCMS has fully considered this requirement and provided users with a flexible and powerful multilingual solution to ensure that your content can reach users around the world and provide a friendly browsing experience in different cultural contexts.

The core strategy of AnQiCMS in implementing multilingual functionality is to treat each language as an independent "site" for management, and to build a complete multilingual system by combining template-based translation mechanisms and user-friendly language switching features.This means that you can not only set different domain names or subdirectories for different language versions of your website, but also manage the content of each language in detail and provide visitors with a convenient language switching entry.

Background configuration - Laying the foundation for multilingualism

To build a website that supports multiple languages, you first need to start configuring from the AnQiCMS backend management system, which mainly involves multi-site management and language package settings.

In AnQiCMS, a multilingual site usually means that you need to configure a separate website instance for each language version.This multi-site management mode allows you to independently set content for different language versions, domain names, and even theme styles, thus ensuring maximum flexibility and maintainability.To start configuring a multilingual site, you first need to enter the 'Multi-site Management' feature in the AnQiCMS backend and add a new site here.When adding a new site, you need to specify a unique domain for each language version (for example, the Chinese site useswww.yourdomain.comEnglish site usageen.yourdomain.com), a separate site root directory (used to store the cache and specific data of the language site) as well as the corresponding database information.This way, each language site has an independent and isolated running environment, ensuring clear data and configuration.

To ensure that the system prompts and built-in text on each language site are displayed correctly, you can go to the "Global Settings" area of the AnQiCMS backend and find the "Default Language Package" option.Here, you can choose the built-in Chinese, English, or other supported language packs for the current site.Please note that the language package here mainly affects the backend interface, system prompts, and some built-in frontend component text of the AnQiCMS system.It will not automatically translate the articles, product descriptions, and other user-generated content you post. These contents need to be translated through subsequent site content management and template translation.

Front-end implementation - Create a seamless switching experience

After completing the basic backend settings, the next step is to implement the true multi-language content display and language switching function on the website's frontend page, which cannot be separated from the template tags and file structure provided by AnQiCMS.

Implement multilingual in front-end templates, AnQiCMS introducedlocalesmechanism and{% tr %}Translation labels. This allows you to centrally manage and translate all static text in the template (such as navigation menu items, button text, copyright statements, etc.)You need to create one in the root directory of the templatelocalesfolder, and create a corresponding subfolder for each language (such aszh-cn/en-usEach language folder should contain a YAML translation file (for exampledefault.yml), which defines translation content in key-value pairs. For example, inzh-cn/default.ymlyou can define\"yourLocation\": \"您的位置\", and inen-us/default.ymldefine\"yourLocation\": \"Your Location\".In the template, when you need to display this text, just use{% tr \"yourLocation\" %}Label, AnQiCMS will automatically load and display the corresponding translated text based on the current site language settings, thus avoiding the麻烦 of copying a set of template files for each language.

To allow visitors to easily switch between different language versions, AnQiCMS provides a powerful{% languages %}The tag can automatically retrieve all the multilingual site information you have configured, including their language names, link addresses, and even corresponding emojis or icons.You can use this tag to build a dynamic language switch menu in a prominent location such as the header or footer of the website.

In the template, by looping through{% languages %}the tags returned bywebsitesSet, you can easily create a link for each language site. Eachitemwill include such asitem.Link(pointing to the URL of the language site),item.LanguageName(Language name, such as "Simplified Chinese", "English"),item.LanguageEmojioritem.LanguageIcon(Fields for displaying language flags or symbols) etc., making it convenient for you to customize the style of the toggle button.

For example, a simple switch code might look like this:

`twig {%- languages websites %} {%- if websites %}

<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 %}

{%- endif %} {%-

Related articles

How can you implement a multi-dimensional filtering function on the article list or product list page (such as by price, attributes)?

I am glad to discuss with you how AnQi CMS can help us achieve multi-dimensional content filtering.In this era of information explosion, users are increasingly pursuing efficiency and personalization in obtaining content.A website that allows users to quickly locate content according to their own needs will undoubtedly greatly improve the user experience and conversion rate.AnQi CMS provides very powerful and flexible functions in this aspect, especially through custom content models and specific template tags, we can easily build multi-dimensional filtering functions on article list or product list pages, just like the "price filtering" commonly seen on e-commerce websites

2025-11-09

What thumbnail processing methods does AnQiCMS support to optimize the effect of images in different display scenarios?

In modern website operations, images are not only an important part of the content, but also a key factor affecting user experience and website performance.A well-managed image system can significantly improve the loading speed, visual appeal, and search engine optimization effect of a website.AnQiCMS understands the importance of image optimization and therefore provides users with a variety of flexible thumbnail processing methods to ensure that images achieve the desired effect in various display scenarios.AnQiCMS provides three core strategies for handling image thumbnails, each suitable for different display needs

2025-11-09

How to display the custom parameters of the product on the product detail page (for example: color, size)?

In website operation, adding custom parameters to the product detail page, such as color, size, etc., is an important link to improve user experience and provide more detailed product information.AnQiCMS (AnQiCMS) can easily meet this requirement with its flexible content model and powerful template system.Next, we will discuss in detail how to display these custom parameters on the product detail page.--- ### Step 1: Define custom fields in the product content model backend One of the core advantages of AnQi CMS is its highly flexible content model

2025-11-09

How to correctly render Markdown-formatted article content as HTML and display mathematical formulas in AnQiCMS?

In AnQi Content Management System (AnQiCMS), we are committed to making content creation and display more flexible and efficient.For users accustomed to writing articles in Markdown format, we provide powerful support, ensuring that Markdown content is correctly rendered into HTML, and can easily handle complex mathematical formulas and flowcharts, bringing vitality to technical documents, tutorial articles, and other content.### Enable Markdown Editor: The First Step of Content Creation Enjoy Markdown Convenience in AnQiCMS

2025-11-09

How to precisely control the display level and sorting order of the navigation menu in AnQiCMS template?

In website operation, a clear and intuitive navigation menu is like a guidepost for visitors to explore the website.A well-designed navigation not only improves user experience but also helps search engines better understand the website structure.AnQiCMS provides a flexible mechanism to help users accurately configure the hierarchy and sorting of navigation menus in the background and implement these controls in the front-end templates. ### Build Navigation Skeleton: Backend Settings Are Key Navigation menu control in AnQiCMS starts from its backend management interface.This is like the blueprint design center of the navigation menu

2025-11-09

Can AnQiCMS set independent display templates for different articles? How to operate?

## AnQiCMS: Create a dedicated display template for every article of yours In our daily website operations, the diversity of content presentation is the key to improving user experience, enhancing brand image, and optimizing SEO effects.Different types of articles often require different layouts and features, such as a deep technical analysis article that may require a more focused reading interface, while a product introduction page may require richer image displays and purchase buttons.So, can AnQiCMS (AnQiCMS) meet the need for setting independent display templates for different articles?I can clearly tell you

2025-11-09

How to display the copyright information, filing number, and other global settings on the front-end page?

The footer usually carries important content such as copyright information and filing number, which not only relates to the professional image of the website, but also the legal requirements and the foundation of user trust.In AnQiCMS, these global settings can be configured and called very conveniently, making your website information clear at a glance.Next, we will learn in detail how to configure and display these key information in AnQiCMS.### Step 1: Configure Global Information in the Background First, you need to log in to your AnQiCMS admin panel, find the Back-end Settings in the left navigation bar.

2025-11-09

How to avoid malicious collection of content in AnQiCMS and add watermarks to images to protect copyright?

In today's world where digital content is increasingly rich and spreads rapidly, protecting the copyright of original content is particularly important.Malicious collection and unauthorized use of images not only harms the creators' labor results, but may also have a negative impact on the website's SEO and brand image.AnQiCMS (AnQiCMS) understands these challenges and therefore incorporates multiple features to help users effectively avoid malicious content scraping and add watermarks to images to protect copyright.In the era of information explosion on the Internet, original content is a valuable asset of the website. However

2025-11-09