How to ensure that AnQiCMS multilingual content switches and displays correctly on the front end?

Calendar 👁️ 59

Today, making a website support multilingual switching and display has become an important link for many enterprises to expand into the international market.AnQiCMS with its flexible architecture, provides us with an efficient way to achieve this goal.This article will delve into how to configure and manage multilingual content in AnQiCMS, ensuring that it can be correctly switched and displayed on the front-end website, thereby providing a high-quality browsing experience for users of different languages.

AnQiCMS Overview of Multilingual Capabilities

AnQiCMS cleverly integrates multilingual content management into its core features.The key to implementing multilingual is the close integration of "multi-site management" and "language packs" as well as "template tags."}This means that you can treat each language version of the website as an independent site to manage, where each site can have its own independent database content, templates, and language configuration, thereby achieving a high degree of customization and isolation.

Back-end configuration: lay a foundation for multilingual support

To ensure that the multilingual content of AnQiCMS is correctly switched and displayed on the front end, a series of basic configurations need to be made in the back end first.

  1. Set default language package.In the 'Global Function Settings' of AnQiCMS backend, you can find the 'Default Language Pack' option.This built-in Chinese, English and other languages for you to choose from.After selecting a language pack, this will affect the display of the system backend interface and some built-in, non-user-generated text on the frontend.For example, some system prompts, button texts, and other elements will be displayed in the selected language.

    However, please note that this settingwill not translate automaticallyContent such as articles, products, and single pages published on your website. These core contents created by users need to be independently created and maintained for each language.

  2. Create different language versions through multi-site managementThe powerful "Multi-site Management" feature of AnQiCMS is the core of the multilingual strategy.You can create a separate site for each target language.For example, if your target audience includes English and Spanish speakers, you can create a name foren.yourdomain.comEnglish site, and a site namedes.yourdomain.comSpanish site.

    When adding a new site in the "Multi-site Management" interface in the background, you need to configure the following information for each language site:

    • Site name: It is convenient to distinguish between different language versions, such as "English site", "Spanish site".
    • Site root directoryEach site should have an independent root directory to store cache, uploaded files, and other data to avoid conflicts. Typically, it starts with/app/followed by a name converted from the domain, such as/app/en_yourdomain_com.
    • website address: This is the access domain name for this language version, for examplehttp://en.yourdomain.com. Please make sure that the domain name has been correctly resolved to your server
    • Administrator account password: Set independent backend management permissions for each site
    • Database nameEach language site has an independent database to store its unique content. It is also recommended to name it using the domain name conversion, such asen_yourdomain_com.
    • Select the template to use: You can choose or customize a dedicated template for each language version to adapt to the layout and design needs of different languages.

    In this way, each language site will have an independent backend, content, and template, providing a solid foundation for the refined operation of different language markets.

Implement front-end template: Ensure language switching matches content

After configuring the site in different languages in the background, how to achieve the correct language switch and content display on the website front-end is the key.This is mainly completed through the template tags provided by AnQiCMS.

  1. Build a front-end language switcherTo allow users to freely choose the language version of the website, we need to provide a language switch menu on the website front end. AnQiCMS'slanguagesLabels can help us easily achieve this. This label will return an array containing information about all configured language sites.

    In the template, you can use it like thislanguagesLabel to build a language switcher:

    {%- languages websites %}
    {%- if websites %}
    <div class="language-switcher">
        <span>切换语言:</span>
        {%- for item in websites %}
        <a href="{{item.Link}}" title="{{item.LanguageName}}">
            {%- if item.LanguageIcon %} {# 优先使用语言图标 #}
            <img src="{{item.LanguageIcon}}" alt="{{item.LanguageName}}" />
            {%- else %} {# 否则使用 Emoji 表情符号 #}
            {{item.LanguageEmoji}}
            {% endif %}
            {{item.LanguageName}}
        </a>
        {%- endfor %}
    </div>
    {%- endif %}
    {%- endlanguages %}
    

    This code will iterate over all the language sites that have been set up and generate a link for each site.item.LinkIt will point to the root directory of the corresponding language site, ensuring that the user can click and correctly jump to the homepage of the language version.

  2. To implement the localization of text in the templateFor fixed text on the website interface, such as navigation menu items, footer information, form prompts, etc., you can use AnQiCMS'str(translate) The tag is for localization. This avoids copying the entire template for each language, making template maintenance more efficient.

    To enable this feature, you need to create a folder namedlocalesThe folder. Inside the folder, create a subfolder for each language (for exampleen-us/zh-cnetc.), and place adefault.ymlfile.

    For example, yourlocales/zh-cn/default.ymlfile content may be:

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

    Andlocales/en-us/default.ymlThe file content might be: “`yaml yourLocation: “Your Location” contactUs: “Contact Us”

Related articles

How does AnQiCMS optimize the URL structure through pseudo-static rules to improve search engine results display?

In today's digital marketing environment, a website's URL structure is not just an access address, but also a key element for user experience and search engine optimization (SEO).A clear and meaningful URL can enhance user trust and help search engines better understand the content of the page, thereby improving the display and ranking of the website in search results.AnQiCMS (AnQi Content Management System) fully understands this, and therefore its design in the field of pseudostatic rules provides powerful tools for website operators to optimize URL structure and stand out in search engines.

2025-11-07

How to set up independent display templates for AnQiCMS documents or categories?

In website operation, we often encounter such needs: some documents need a unique display method, the article list of a certain category needs a special layout, or a single page needs a unique design.AnQiCMS knows the importance of this personalized demand and provides flexible template settings to easily set independent display templates for documents, categories, and even single pages.This can not only help you better meet the diversity of content display, but also greatly enhance the user experience and the brand image of the website.Why do we need an independent display template?

2025-11-07

How does AnQiCMS handle images in document content to optimize front-end display (e.g., Webp, compression)?

Images are an indispensable part of website content, they can make the page more attractive and convey richer information.However, if images are not optimized, the large file size often leads to slow website loading, severely affecting user experience and search engine rankings.AnQiCMS provides a series of powerful optimization functions when processing images in document content, helping us easily cope with these challenges to ensure that the front-end display is both beautiful and efficient.

2025-11-07

How to create and manage multiple sites in AnQiCMS to achieve independent content display?

AnQiCMS is an efficient enterprise-level content management system, and its multi-site management function is undoubtedly an important tool for many enterprises and operators to improve efficiency and segment the market.By creating and managing multiple independent sites under an AnQiCMS instance, we can flexibly provide customized content display and services for users of different brands, business lines, or regions.

2025-11-07

How does AnQiCMS improve website page loading speed and display experience through static caching?

In the digital age, the loading speed of websites has become a key indicator of user experience and search engine rankings.A website that responds quickly can effectively enhance user satisfaction, reduce the bounce rate, and bring better exposure to the content.AnQiCMS is a content management system focused on high performance and efficiency, and the static caching mechanism plays a crucial role in improving website loading speed.

2025-11-07

How to use AnQiCMS built-in tags to retrieve and display system configuration information (such as website name, Logo)?

It is crucial to maintain consistency and ease of updates in website operation and management.AnQiCMS as an efficient content management system fully considers this point, providing powerful built-in tag functions, allowing the global configuration information of the website (such as website name, Logo, filing number, etc.) to be easily dynamically obtained and displayed in the front-end template.This means you do not need to hardcode, just make a change in one place in the background, and all pages referencing this information will update automatically, greatly enhancing the maintainability and operational efficiency of the website.

2025-11-07

How to include common header and footer code snippets in AnQiCMS templates?

It is crucial to maintain consistent page layout, improve development efficiency, and reduce maintenance costs in website construction and content management.AnQiCMS as an efficient content management system provides a flexible template mechanism, allowing us to easily reuse common code snippets across different pages, such as the website header navigation, footer information, or sidebar, etc.This article will delve into how to elegantly introduce common header and footer code snippets in the AnQiCMS template, helping you better organize template files and improve the overall maintenance efficiency and user experience of the website.

2025-11-07

How does AnQiCMS achieve adaptive display for PC and mobile pages?

In today's era of coexistence of multiple devices, whether a website can present a good user experience on different screen sizes is directly related to its influence and commercial value.Whichever device the user accesses, whether it is a desktop computer, laptop, tablet, or smartphone, they all expect to see a page with clear layout and easy operation.AnQiCMS (AnQiCMS) is well aware of this core requirement and therefore integrated a variety of flexible adaptive display strategies from the outset to ensure that your website can be presented in **status** on any device.AnQi CMS provides three main website display modes

2025-11-07