Language for individual pages/links

DeCysos

Phoenix Foto Service
License owner
screen_indulinks_dev.png

💡Describe your idea
Since English is an international language, this is the only one that is available on my page besides my native language. In addition, other languages are currently not negotiable for me.

As indicated in the link below, I had been looking for a way to adapt my categories and self-created pages / links to another language.
For the categories that worked wonderfully.
Unfortunately, I have problems with the self-created pages / links.
Unfortunately, that does not work there.
Maybe it would be very helpful if someone could give me a food for thought or the function will be implied in a next update.

Which would be very nice for V4, if you could translate the language as in mfscript.com additionally via the admin menu. At least it would be nice if in V4 create a category or other self-created content a field where you can enter a translation (for a particular language)

👏Where did you saw this?
Even thinking about it ;)

🔥Interest outside our community

🛠What have I already tried?
in this file (code)

/app/themes/Peafowl/header.php:
            <?php
                    if (get_pages_link_visible()) {
                        ?>
            <li data-nav="about" class="phone-hide pop-btn pop-keep-click pop-btn-delayed">
                <span class="top-btn-text"><span class="icon icon-info tablet-hide laptop-hide desktop-hide"></span><span class="text phone-hide phablet-hide"><?php _se('About'); ?></span><span class="arrow-down"></span></span>
                <div class="pop-box arrow-box arrow-box-top anchor-right">
                    <div class="pop-box-inner pop-box-menu">
                        <ul>
                            <?php
                                foreach (get_pages_link_visible() as $page) {
                                    ?>
                            <li<?php if ($page['icon']) {
                                        echo ' class="with-icon"';
                                    } ?>><a <?php echo $page['link_attr']; ?>><?php echo $page['title_html']; ?></a></li>
                            <?php
                                } ?>
                        </ul>
                    </div>
                </div>
            </li>
            <?php
                    } ?>
I tested it with: <?php echo _s($page['title_html']); ?>
This does not work.
 

Rodolfo

Chevereto Developer
Chevereto Staff
If I understand it correctly, you are suggesting to have URLs like these:

Code:
(en) /category/animals
(es) /categoria/animales
(de) /kategorie/tiere
(and so on)

I really like your idea, and the new router that I made for Chevereto has the flexibility to provide language based URLs like those. Basically, the base language is set for both the URLs and content.

There is a huge value in being able to provide language based URLs because the url itself has a meaning in every language.

I will make sure to add this flexibility to the system.
 

DeCysos

Phoenix Foto Service
License owner
Not quite right.
There should not be a language version for the link but only for the name of the link.

For a URL / Link, it is also nice, but not quite as advantageous for search engines etc, except if you would then route it internally.
-------------
Regarding the categories, I have already got it that the name of the category changes depending on the language version. See: https://pfs.red - in english and german.
-------------------
What this is about in this thread is:
As you can see in the picture I have set English as language. But the name will continue to be in German.
Why? I am German and named the names of the links / pages in German.
What I want: For each language version or at least for English a translation.
As stated in the code, there is a variable for it. However, there can not be the following: <?php echo _s($page['title_html']); ?>

The text is not translated.
 

Rodolfo

Chevereto Developer
Chevereto Staff
Text won't be translated just by using the _s function. That is just a placeholder for gettext, it won't ever work for what you want unless you add the language strings to the po file.
 

DeCysos

Phoenix Foto Service
License owner
/app/content/languages/overrides/en.po:
#: START Extra English

#: About/Über Links Deutsch/English
msgid "Kontaktformular"
msgstr "Contact form"
I did it that way...
/app/themes/Peafowl/header.php:
                    <div class="pop-box-inner pop-box-menu">
                        <ul>
                            <?php
                                foreach (get_pages_link_visible() as $page) {
                                    ?>
                            <li<?php if ($page['icon']) {
                                        echo ' class="with-icon"';
                                    } ?>><a <?php echo $page['link_attr']; ?>><?php echo _s($page['title_html']); ?></a></li>
                            <?php
                                } ?>
                        </ul>
                    </div>
But <?php echo _s($page['title_html']); ?> says: <span class="btn-icon icon-chat"></span> Kontaktformular
So I have to change the en.po into the following content:
/app/content/languages/overrides/en.po:
#: START Extra English

#: About/Über Links Deutsch/English
msgid "<span class="btn-icon icon-chat"></span> Kontaktformular"
msgstr "<span class="btn-icon icon-chat"></span> Contact form"
for it to work?
or where is $page['title_html'] pulled?
 

DeCysos

Phoenix Foto Service
License owner
I have found the function....
\app\lib\classes\class.page.php:
    public static function fill(&$page) {
        $page['title_html'] = $page['title'];
        $type_tr = [
            'internal'    => _s('Internal'),
            'link'        => _s('Link')
        ];
        $page['type_tr'] = $type_tr[$page['type']];
        switch($page['type']) {
            case 'internal':
                $page['url'] = G\get_base_url('page/'. $page['url_key']);
                // Workaround default file_path
                if(empty($page['file_path'])) {
                    $filepaths = [
                        'default'    => 'default/',
                        'user'        => NULL // base
                    ];
                    $file_basename = $page['url_key'] . '.php';
                    foreach($filepaths as $k => $v) {
                        // if($k == 'default') {
                        //     //$file_basename =  $page['url_key'] . '.php';
                        // } else {

                        // }
                        if(is_readable(self::getPath($v) . $file_basename)) {
                            $page['file_path'] = $v . $file_basename;
                        }
                    }
                } else {
                    $page_extension = G\get_file_extension($page['file_path']);
                    // Disable PHP pages here
                    if(G\get_app_setting('disable_php_pages') and $page_extension == 'php') {
                        $page['file_path'] = G\str_replace_last($page_extension, 'html', $page['file_path']);
                    }
                }
                $page['file_path_absolute'] = self::getPath($page['file_path']);
                if(!file_exists($page['file_path_absolute'])) {
                    try {
                        self::writePage(['file_path' => $page['file_path'], 'contents' => NULL]);
                    } catch(Exception $e) {} // Silence
                }
            break;
            case 'link':
                $page['url'] = G\is_url($page['link_url']) ? $page['link_url'] : NULL;
            break;
        }
        $page['link_attr'] = 'href="' . $page['url'] . '"';
        if($page['attr_target'] !== '_self') {
            $page['link_attr'] .= ' target="' . $page['attr_target'] . '"';
        }
        if(!empty($page['attr_rel'])) {
            $page['link_attr'] .= ' rel="' . $page['attr_rel'] . '"';
        }
        if(!empty($page['icon'])) {
            $page['title_html'] = '<span class="btn-icon ' . $page['icon'] . '"></span> ' . $page['title_html'];
        }
    }
its that right ?
 
Top