WebsiteBaker Support (2.11.x) > General Help & Support
Multilanguage
jacobi22:
start at the begin, step by step
#1 - i start with a fresh wb 2.11, all filters activated, but not OpF, JQueryUI, these are the defaults after a new install
#2 - add some pages, BG and EN with type "menu-link", Home-BG and Home-EN with type "wysiwyg" (only to try it). Be sure, that every page has the correct language. Every Subpage (Child) of an Mainpage like BG or EN must have the language from this Parent-Page. it's recommended, to start with the main language and adding there all needed subpages / child for this tree-part
Example-tree here -> https://i.gyazo.com/cc254a6f014b0b44d3911e0e3e282776.png
#3 - the page code
if you have the exact page structure in all language-tree's (here under BG or under EN), WB set the pagescodes automatically, if you click in one page on the pagesettings on the link "pagecode". it is very important, that every page has the correct page code. otherwhise, you get a error, when you switch the pages or you get a redirect to the main-page.
#4 - the code for the index.php
i add your template to my installation (in a fresh WB 2.11). The code is a exact copy from the example in DefaultTemplate (WB-Package) - it works without problems and i can switch the languages from page to page
1. your code to prevent this file for directly access (outside from WB)
if (!defined('WB_PATH')) die(header('Location: ../../index.php'));
Redirect's to a higher level with a relative path like this example (with ../) is a security risk. its possible, to manipulate links like this. it is possible, to come with a manipulated link out of this wb-installation and directly into the server document root or more
WB use since WB 2.10 an prevention like this without a redirect
/* -------------------------------------------------------- */
// Must include code to stop this file being accessed directly
if (!defined('SYSTEM_RUN')) {header($_SERVER['SERVER_PROTOCOL'].' 404 Not Found'); echo '404 File not found'; flush(); exit;}
/* -------------------------------------------------------- */
2. - read the actual language of the selected page
$sPageLang = strtolower(isset($wb->page) || ($wb instanceof frontend) ? $wb->page['language'] : 'EN');
means in simple words: if it's not possible to read the page language, set it to EN (english - if you dont have a english page in this project, change the code to your main language - in your case maybe the favorite Language BG. Write this Language-code in upper Letter. if you not sure about the correct language code, take a look into the favorite language file in folder /languages
3. read the actual page-id
$iPageId = (defined('PAGE_ID') ? PAGE_ID : 0);
it's important to use the the flag menu
4. the flag menu - controler
$iMultiLang = 0;$sMultiLang = ''; if (function_exists('language_menu')){$sMultiLang = language_menu('png',false); $iMultiLang = intval(!empty($sMultiLang) ? 1 : 0);}
check, if it possible to use the function, result set this switch to true or false
language_menu('png',false) - possible file type's gif, png, svg
5. build href-lang links (optional)
the follow code is only needed, if you want the href-links. if you use this, be sure, that this code in placed behind the open <head> and the closing </head>
--- Code: ---if (!function_exists('LangPadeId')) {function LangPadeId(){return $iPageId;}}
if (function_exists('LangPadeId')&&$iMultiLang) {
?>
<!--
<link rel="alternate" hreflang="x-default" href="[wblink<?php echo LangPadeId($sPageLang);?>]" />
<link rel="alternate" hreflang="de" href="[wblink<?php echo LangPadeId('DE');?>]" />
<link rel="alternate" hreflang="en" href="[wblink<?php echo LangPadeId('EN');?>]" />
-->
<?php
}
?>
--- End code ---
#6 - the flag menu - somewhere between open <body> and closing </body>
the div-block around is only a example, important is the php-code there
<div id="lang" style="height: 2.925em;">
<?php if(trim($sMultiLang)!=''){ ?>
<?php echo $sMultiLang; ?>
<?php } ?>
</div>
#7 - working without filters
if your project dont use any filters, specially without FrontendCSS, FrontendJS, RegisterModFiles, SnippetJS, you have to include the file /modules/WbLingual/include.php manually. (and also every other include file from other snippets)
--- Quote ---You didn't understand me dbs, when I put the codes from the default template the page crash (that's why I removed them and you didn't saw them) ... the menu disappear and only one word stay somewhere behind the logo ... and the EN language doesn't work properly.
--- End quote ---
for example - if i remove the engine of your car, you cannot drive. And if you add the engine again and it doesnt run and because ot this, you remove it again, the car will not drive - you understand? :wink:
Step #1 - #4 are only some hints, very important are #2 and #3
from the points 1 - 7, you can remove No.5, if not needed, but all other things are neccessary. every little step is important, it's like a car - if i forgot to add the fuel, the car will not drive, if i forget to add the battery, the car will not drive e.g.
P.S. go to your advanced wb-settings - server settings, set PHP-Errors to production or development for the time, where you work on it, so you get some more informations about possible errors in your error log
if you get more problem's, give us also the used PHP-version - see info-Window here ->
rumen:
I think the problem comes from the previous installation. I installed 2.10 with multi language module. After that I decided to check 2.11 .... I upgraded and the multi language crashed. And all codes from the new default template either crash the template as a whole or crash the menu or there is no any effect .... OK never mind it is not an issue. I can try to make a new copy of 2.10 at the local disk and install 2.10 with the old language method.
jacobi22:
normalize, the upgrade of the WbLingual-Module in WB 2.11.0 delete the old mod-multilingual-Module in /modules/mod_multilingual
be carefull: wb 2.10.x use a different method to call the multi-lingual menu / flag menu, dont use a mix between files and function call
rumen:
OK
1. Easy Multi language - uninstalled
2. The WB upgraded - as a whole ...
3. Instructions from the Readme.txt from Module: WebsiteBaker Lingual Switcher Add-on 1.0.0-dev.4 - applied
And again nothing and too many things crashed.
Don't worry and don't loose your time. I will make the page again with 2.10 and everything will work.
jacobi22:
i did'nt understand, why you mix everything and not wondering, that you have problems now
1. Easy Multi language - uninstalled - rewrite the pages database table and destroy the page structure, specially for the page-code-field, only possible to repair with a new install of WB
Module is deprecated since 8 years!
2. WebsiteBaker Lingual Switcher Add-on 1.0.0-dev.4 - why do you think the RC2 and WB 2.11 stable contain a new module version?
it make's no sense to write here more and more instructions, if nobody read it :roll: :roll:
follow my instructions in the top in a WB 2.11 and everything works
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version