horst Posted March 6, 2019 Share Posted March 6, 2019 @szabesz the invision board software has eaten your link! Please add it again and add a new line after it. 1 Link to comment Share on other sites More sharing options...
FlorianA Posted May 3, 2020 Share Posted May 3, 2020 After some tedious experiments, I finally managed to switch my site's default language from English to German both in frontend and backend. I am reliefed but not satisfied because it was a terrible hack: Starting with @mscore's SQL script, I added a condition to make sure that field texts are only swapped if a translation exists SET s1.data = s1.data123, s1.data123 = s2.data WHERE s1.pages_id = s2.pages_id AND s1.data1019 != ''; Especially important for backend field without translation, otherwise the backend text will get broken. Then, I added some lines in order to update the option names for FieldtypeOptions: UPDATE fieldtype_options s1, fieldtype_options s2 SET s1.title = s1.title123, s1.title123 = s2.title, s1.value = s1.value123, s1.value123 = s2.value WHERE s1.fields_id = s2.fields_id and s1.option_id = s2.option_id; The following statements are necessary for keeping the correct translation files for both languages (let 124 be the page id of the default language): update field_language_files set pages_id = 123 where pages_id = 124; update field_language_files_site set pages_id = 123 where pages_id = 124; Unfortunately, since translation files are stored in the assets, it is also necessary to swap the corresponding asset directory names: files/123 to files/124. The final step is changing the title of the new non-default language ("deutsch" to "english") and the language names respective. I can't understand why there's still no out-of-the-box solution for this use-case, which is IMHO not so unusual. I also would prefer a PW API solution like @gebeer's one, but I couldnt' find out how to iterate over really all stuff I need (including backend) ... 3 Link to comment Share on other sites More sharing options...
gebeer Posted May 4, 2020 Author Share Posted May 4, 2020 @Florian Thanks for sharing! I also wonder why we do not have this in the core. Link to comment Share on other sites More sharing options...
FlorianA Posted May 5, 2020 Share Posted May 5, 2020 Just noticed that I'm still not finished ? The field labels and descriptions are still in the wrong language. This cannot be fixed by simple SQL since these values are JSON-encoded in the data column of the fields table ? Maybe I'll try to write a PHP script with a mixture of PW API and raw SQL calls because I'm not familiar enough with PW internals for a cleaner solution. Maybe I already could be finished with the PW port of my site, but this default language issue wastes lots of lots of time ... on the other hand, it seems to be a blocker for me forcing my users to fill in all (English) default language fields if the site's text is by 95% in German. Link to comment Share on other sites More sharing options...
gebeer Posted May 6, 2020 Author Share Posted May 6, 2020 8 hours ago, FlorianA said: it seems to be a blocker for me forcing my users to fill in all (English) default language fields if the site's text is by 95% in German. If I understand this correctly, then your default language should be German. What was the reasoning behind switching languages in your case? If you want to write a PHP script, maybe my old script can give you some pointers. I wrote that years ago when I wasn't very experienced in working with the PW API. So there sure is much room for improvement. Link to comment Share on other sites More sharing options...
horst Posted May 6, 2020 Share Posted May 6, 2020 @FlorianA maybe there is / was a misunderstanding? (I haven't read the thread, only the last posts) You are able to do: sites only in german, sites with german as default language, and (multiple) other language(s) added in ProcessWire with a snip, -- IF you start a new site right with the desired default language. Then your users only have to fill in the german fields, (and only optional other language(s)). Link to comment Share on other sites More sharing options...
FlorianA Posted May 7, 2020 Share Posted May 7, 2020 On 5/6/2020 at 11:28 AM, horst said: @FlorianA maybe there is / was a misunderstanding? (I haven't read the thread, only the last posts) You are able to do: sites only in german, sites with german as default language, and (multiple) other language(s) added in ProcessWire with a snip, -- IF you start a new site right with the desired default language. Then your users only have to fill in the german fields, (and only optional other language(s)). @horst, that sounds really promising, unfortunatley I don't have a clue how to do this. I've just installed a new site from the ZIP file (master 3.0.148) with the "Multilanguage" site profile, but I couldn't see a possibility to prevent the default language from being English. I couldn't find any documentation about it either. I'll greatly appreciate any hints how to do the snip ? 1 Link to comment Share on other sites More sharing options...
horst Posted May 8, 2020 Share Posted May 8, 2020 (edited) Summary: When you start a new site and the default not should be english: 1) enable languages support 2) set Title / Label of the default language to your desired none english native language, (e.g. 'Deutsch' (German)) 3) drop in the none english language pack (for admin backend) into the default language, (e.g. german langpack) Now you are ready to start with a single language site of your choice. If you want to use a multi language site, you now can add as many additional languages you want. If one of them should be english, you add it, but do not need to apply a language pack. 4) add a new language to it and drop in a language pack for any none english language or simply don't drop in a language pack to get the english version (but not as the default one!) For single language sites you only need to enable languages support, NOT language inputfields!, NOT language pagenames!, only basic language support, - to be able to change the default languages name and its lang pack! Of course, if you plan a multilanguage site, you also will need language pagenames and language inputfields, but not if you only need a none english backend. ? So, if you know at the beginning of a new site / project what has to be the default language, it is done with a snip. Only disadvantage is, if you need to switch the default language later on, when already content was filled into a site. These seems to be very rare cases in real life. And for that I think have read a complete step by step guide from @BitPoet within the last two or three month somewhere. (Is this right @BitPoet ? and sorry for ping you here) You also can read it here: Edited May 8, 2020 by horst 7 Link to comment Share on other sites More sharing options...
kongondo Posted May 8, 2020 Share Posted May 8, 2020 1 hour ago, horst said: Summary: When you start a new site and the default not should be english: @horst, Thanks for the write-up! If you possibly can, for newbies, could you please make a diagram/flow chart for the instructions? Or at least add more details please? For instance: 1 hour ago, horst said: 2) set Title / Label of the default language to your desired none english native language, (e.g. 'Deutsch' (German)) Where should this be done? ? 1 hour ago, horst said: 1) enable languages support Where should this be done? What does the user need to enable and/or download? ? Etc. Thanks for considering. 2 Link to comment Share on other sites More sharing options...
szabesz Posted May 8, 2020 Share Posted May 8, 2020 (edited) There seems to be a different opinion, see: https://processwire.com/talk/topic/21534-how-to-change-the-default-language-in-processwire-cms/?tab=comments#comment-185533 Still, I also use the setup Horst suggests and I have not found any drawbacks of it so far. Edited May 8, 2020 by szabesz typo 2 Link to comment Share on other sites More sharing options...
bernhard Posted May 8, 2020 Share Posted May 8, 2020 Quote However, I noticed that it is a bad practice to modify the default language (english) with language files. Instead you should add russian as an ADDITIONAL language and then set the guest user to this language (for the frontend) and also your admin user, so the PW admin is also in russian. Maybe @dotnetic can elaborate why this is a bad practice? 4 Link to comment Share on other sites More sharing options...
horst Posted May 8, 2020 Share Posted May 8, 2020 (edited) Ok, I have read that linked post. But one question is: What kind of default URLs do we get in a multilanguage site when following @dotnetic's suggestion. (@Jens: ?) I have created a series of screenshots, a full walk-through, of my suggested way, but I don't want to publish it, if it wouldn't be correct or if there be a better way. So here are my questions: When I only want to have a single language page in none english, what is to do then? How will the page pathes urls work out then with a second language set? When I want to have a multi language site with none english default, but with english as second lang, what is to do? How will the pages URLs work out for the none english default and the english sub language? EDIT: @bernhard, you was a bit faster, but I have more in depth questions. ? Edited May 8, 2020 by horst 2 1 Link to comment Share on other sites More sharing options...
horst Posted May 8, 2020 Share Posted May 8, 2020 Change Default Language to be None-English | Walk Trough When you start a new (single) language site and the default language shouldn't be English, you can change it this way: Go to the modules core section: Select the Language ones by the filter function: We have four language related modules here, but for a single language site in none english, we only need the base module, named "Languages Support". So go on and install it. After that, you can leave it, ... ... and switch to the newly created Language section under SETUP: Select the default language Enter your new language name or its Shortcut and save the page. I will use DE for a single language site in german here as example: Now I go to the ProcessWire online modules directory, down to the subsection for language packs and select and download my desired (german) one: After downloading a lang pack as ZIP, I go back into my SETUP > LANGUAGES > default language page in admin, select the downloaded lang pack ZIP and install it: After the ZIP is uploaded, the files are extracted and installed, most of my screen is already in the new default language. To get all fully switched, we save and leave that page, ... ... and completely logout from the admin. Now, of course, we directly login back, ... ... and see, that now also the cached parts of the admin have switched to the new default language. ? That was it for a single language site in none english. If you want to have a multi language site, just add more languages to the SETUP > LANGUAGES section. When using a multi language site, I think you also want to use multi language input fields, and maybe different page names for your language page pendents. If so, you need to go into MODULES > CORE > filter LANGUAGE and install what you need or want to use of it, (if not already done). Thanks for reading and happy coding, ? 5 3 Link to comment Share on other sites More sharing options...
FlorianA Posted May 9, 2020 Share Posted May 9, 2020 On 5/8/2020 at 1:06 PM, horst said: Summary: When you start a new site and the default not should be english: ... @horst, thank you very much for your post! Things could be so easy with a good tutorial ? I think I'll try it this way. However, I've already put a lot of work into my site, but it isn't productive yet, so I think it isn't too late for a clean re-start with new fields and pages. 2 Link to comment Share on other sites More sharing options...
horst Posted May 10, 2020 Share Posted May 10, 2020 22 hours ago, FlorianA said: Things could be so easy with a good tutorial Hi Florian, I (temporary) have unhidden the post above yours with a walk through screenshot series. Have a good restart and fun with building your site! ? 2 Link to comment Share on other sites More sharing options...
dotnetic Posted May 10, 2020 Share Posted May 10, 2020 @horst's tutorial should be a sticky post in the forum. Link to comment Share on other sites More sharing options...
bernhard Posted May 10, 2020 Share Posted May 10, 2020 On 5/8/2020 at 2:11 PM, bernhard said: Quote However, I noticed that it is a bad practice to modify the default language (english) with language files. Instead you should add russian as an ADDITIONAL language and then set the guest user to this language (for the frontend) and also your admin user, so the PW admin is also in russian. Maybe @dotnetic can elaborate why this is a bad practice? @dotnetic any comment on this? PS: Maybe you could link to that post in your language pack's readme ? 1 Link to comment Share on other sites More sharing options...
dotnetic Posted May 10, 2020 Share Posted May 10, 2020 @bernhard Yes, I was just about to write about it ? I have reconsidered my statement, reviewed the procedure, and revoke the statement that it is bad practive. In my project there were some problems with languages at that time, but I can no longer reproduce them. I see no problems with the procedure described by Horst. 3 Link to comment Share on other sites More sharing options...
bernhard Posted May 10, 2020 Share Posted May 10, 2020 7 minutes ago, bernhard said: PS: Maybe you could link to that post in your language pack's readme ? Thx ? Please not the statement that I added later ? 2 Link to comment Share on other sites More sharing options...
dotnetic Posted May 10, 2020 Share Posted May 10, 2020 24 minutes ago, bernhard said: PS: Maybe you could link to that post in your language pack's readme Did that. New README with updated instructions is live 1 Link to comment Share on other sites More sharing options...
kongondo Posted May 1, 2022 Share Posted May 1, 2022 Cross-posting that @horst's tutorial above subsequently became a tutorial in the Tutorials Forum here: Thanks. 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now