How to implement multi-language content switching and display on AnQiCMS websites?

Under the wave of globalization, website multilingual support has become a necessary condition for enterprises to expand into the international market.AnQiCMS as an enterprise-level content management system, fully considers this requirement and provides a set of efficient and flexible solutions to help users easily switch and display multilingual content.

The logic of AnQiCMS's multilingual implementation

AnQiCMS implements the core strategy of multi-language content switching and display, which is based on its powerful "multi-site management" function.It does not use an automatic translation mode, but treats each language version as an independent website instance for management.This means that your Chinese website, English website, Japanese website, etc., will all be independent sites in the AnQiCMS backend, each with its own independent domain (or subdomain, subdirectory structure), content database, and template configuration.

In the system settings, although AnQiCMS provides an option for the 'default language package' to switch the display language of the back-end management interface or the built-in少量system text (such as some prompt information), this is limited to the system level.For the actual content published on the website, such as articles, products, category names, etc., AnQiCMS requires you to independently enter and maintain the corresponding language content for each language site.This design concept ensures the accuracy, professionalism, and relevance of content in different language versions, avoiding semantic bias that may arise from machine translation.

Set up and configure a multilingual website

To implement a multilingual website, you first need to use the 'Multi-site Management' feature of AnQiCMS.In the background, you can create multiple site instances, each corresponding to a target language.For example, you can create a main site for Chinese content, and then create an English site, a Japanese site.When creating these new sites, you need to specify a separate domain name or subdomain (such asen.yourdomain.comorjp.yourdomain.comAnd configure the corresponding database

After completing the site creation, you can log in to the backend of each language site, independently publish and manage content based on the characteristics of the language and user needs.This means that your English article needs to be manually translated and published on English sites, while Japanese product information is published on Japanese sites, and so on.This independent management approach allows you to localize content according to the market characteristics of different regions, even adjust marketing strategies and SEO keywords.

How to implement language switching and display on the front end

On the front end of a website, users will usually see a language switcher that allows them to choose their preferred language. AnQiCMS provides{% languages websites %}Such template tags help you easily build such a toggle function.

For example, in the public header or footer of your website template, you can insert the following code to generate a language switch menu:

{%- 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 %} {# 否则显示语言Emoji或名称 #}
        {{item.LanguageEmoji}} {{item.LanguageName}}
        {% endif %}
    </a>
    {%- endfor %}
</div>
{%- endif %}
{%- endlanguages %}

This code will loop through all the language sites you have created in the background and generate a toggle button with its link, language name, and optional icon or Emoji.When the user clicks on a link for a language, they will be redirected to the corresponding website instance for that language.

Once a user accesses a specific language site through the language switcher, all tags used for content display on the page, such as retrieving a list of articles, are displayed.archiveListTo obtain category details.categoryDetailIt will automatically extract content from the database of the current language site.This means you do not need to write different content calls for each language, AnQiCMS will automatically recognize the language environment of the current site and display the corresponding content.

SEO optimization: Hreflang tag

For the SEO of multilingual websites,hreflangThe tag is crucial. It can tell the search engine which pages are alternative language versions of the same content, thus avoiding duplicate content issues and ensuring that the search engine displays the correct language content to users in the corresponding language region.

AnQiCMS also supports dynamic generation in templateshreflangtags. You can add the following code in the<head>area:

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

This code will generate a label for each language sitelinkLabel, specify the alternative language version and the corresponding URL to effectively improve the performance of multilingual websites in international search engines.

Summary

AnQiCMS through its unique multi-site management feature provides a powerful and flexible solution for switching and displaying multilingual content.Although content translation and entry require manual completion, this model ensures the quality of localization and SEO advantages.From the backend site configuration to the frontend language switcher and SEO optimization, AnQiCMS provides comprehensive support to ensure that your website can better serve global users.


Frequently Asked Questions (FAQ)

1. Does AnQiCMS support automatic content translation?AnQiCMS currently does not provide the function of automatic translation of content.It adopts an independent site content management mode, you need to manually translate and enter the corresponding language content for each language site.This ensures the quality and localization accuracy of the content.

2. How to set up independent domain names or subdomains for different language versions?In the AnQiCMS backend "Multi-site Management" feature, you can specify an independent domain name or subdomain for each new language site created.Before this, you need to correctly resolve these domain names and point them to the installation directory of AnQiCMS on your server (such as Nginx, Apache) or DNS provider, ensuring they can be accessed normally.

3. Will the website URL change after language switching?Yes. As AnQiCMS treats each language version as an independent website instance, language switching usually leads to a change in URL.For example, from the main site'syourdomain.comSwitching to the English site may change toen.yourdomain.comor it can be according to your configuration,yourdomain.com/en/Such a subdirectory structure. This is clear and beneficial for search engine recognition and user experience.