Language Flags on Menu

How can i add another flags here like English/Russian flags ?

In System Settings i searched localizator but i cant find.

I never used the Localizator extra, but there seems to be a snippet getLocales to output a list of languages. Maybe this snippet gets used on your site.


Like I said in an earlier post, every MODX site is unique. So you have to figure out where exactly on your site these flags are output and then see if you can change it.

Start with the template. Check what template your resource uses and then go to this template (Tab “Elements” → vertical tab “Templates”) and check if you can find the line where the flags are output.

If the flags are not directly output in the template, then search for a chunk that is included in the template with a tag like this: [[$someChunk]].

I’ll check it soon like you said. Thanks to your support, I am very enthusiastic about this system.

Meanwhile, there is a getLanguageTopics. From elements/snippets i checked, but i cant find any code to add extra language flag.

Is this a custom snippet? Are you sure this snippet is used to output the flags?
What is the code of this snippet?

I added the code and images. There is a getlanguages and localizator. I’m not sure which one is added flag in the header.


<?php
$output = "";
$pdo = $modx->getService('pdoTools');

$uri = $_SERVER['REQUEST_URI'];
if(substr($uri, 0, 1)) {
    $uri = mb_substr($uri, 1);
    $tmp = explode('/', $uri);
    if($path = $tmp[0]) {
        $tmp = $modx->getObject('localizatorLanguage', array('http_host:LIKE' => "%/{$path}/"));
        if($tmp) {
            $uri = str_replace("{$path}/", "", $uri'54');
        }
    }
}

$protocol = 'https://';
$languages = $modx->getIterator('localizatorLanguage', ['active' => 1]);
foreach($languages as $language) {
    if(mb_substr($language->http_host, -1) == '/') {
        $placeholders = array(
            'cultureKey'=>$language->key,
            'active'=>$language->key == $modx->localizator_key ? 'active' : '',
            'url'=>$protocol . $language->http_host . $uri,
        );
    } else {
        $placeholders = array(
            'cultureKey'=>$language->key,
            'active'=>$language->key == $modx->localizator_key ? 'active' : '',
            'url'=>$protocol . $language->http_host . '/' . $uri,
        );
    }
    $output .= $pdo->getChunk($tpl, $placeholders);
}

return $output;

getLanguages could be the correct snippet. It seems to be based on the code from the readme file on github (with some code changes).

Can you find the position in the template (or a chunk) where this snippet is called ({'!getLanguages' | snippet} or maybe [[!getLanguages? &tpl=`...`]])? What is the value of the tpl property?


In the manager when you go to the top menu “Extras” → “localizator” → tab “Localization”. Are there even more languages in the grid than english and russian that are active?

" “Extras” → “localizator” → tab “Localization” in this part, i added 4 language but two language not seen on header.


You really have to find the place in the template (or in a chunk) where these flags are output.

As these flags are at the top of the page, look at the top of the template (right after the opening <body> tag). Maybe a chunk is used. Possibly named something with “Header”.

I searched with the app. There is only the following code in the caches.

Code: src=“/template/img/flags/uk.png”

Meanwhile, in chunk, i saw section language 1-2

Codes like this;

<div class="dropdown-item">
    {if $active != 'active'}
        <a class="{$active}" href="{$url}"><img class="imglang {$active}" src="/template/img/flags/{$cultureKey}.png" alt="{$cultureKey}"></a>
    {else}
        <div class="{$active}"><img class="imglang {$active}" src="/template/img/flags/{$cultureKey}.png" alt="{$cultureKey}"></div>
    {/if}
</div>

This is the code to output one single flag. But where is this chunk used?

Maybe check the other chunks (the one called “header” seems promising) or the template to see if you can find a reference to “section-langs-1” there.


The relevant code is (usually) stored in the database and not in a file.
(database table modx_site_htmlsnippets for chunks, modx_site_templates for templates, modx_site_snippets for snippets, etc.)

I found in chunks/toplist as you said.

Where can I edit for each language page? From Templates ?

For example, main page is EN. In other language pages i want to make same with en design.

domain.com/ru/
domain.com/cn
domain/tr

Where can I find the home page for each language and all the titles I’ve opened before?

There are no different pages for the different languages.
There is a single page for all the languages and parts of the page are then replaced according to the specific request.

For example {$_modx->resource.pagetitle} either returns the value of “pagetitle” from the resource, or what you entered in the tab “Localization” for all the other languages.

Screenshot 2022-10-16 at 14-14-27 Editing Some Page MODX Revolution

The template and chunks are the same for all languages.

Where did you open the part in the picture? Am I going to edit every page including the main page from the place you show in the picture? English page is ready in advance. I want to make the chinese page the same as the english page.

I am opening from the website part for every page, is this true ?

Open the “Localization” Tab

Then either add a new translation or edit an existing one with right-click → “Change” (or click the “Change” button in the column “Actions”).

Thank you friend, i did bcs of you.