dragan Posted July 30, 2013 Share Posted July 30, 2013 Thanks again for the heads-up. I thought I had removed / disabled all old modules that were in place when I started out. I definitely do want to use the newer method with LanguageSupportPageNames. Guess I have to play Sherlock Holmes now and take another look if there's anything left that interferes with the latest LSPN method. Question then: With LanguageSupportPageNames, is it still necessary to enable URL-segments for each template? Or is that also obsolete now? Perhaps that's causing all the issues I'm encountering? (we don't have any pagination, so that's no issue) Link to comment Share on other sites More sharing options...
Wanze Posted July 30, 2013 Share Posted July 30, 2013 Question then: With LanguageSupportPageNames, is it still necessary to enable URL-segments for each template? Or is that also obsolete now? Perhaps that's causing all the issues I'm encountering? (we don't have any pagination, so that's no issue) No it's not. Unless you need urlSegments for other purposes. I suggest to make another installation with Pw dev to test out the new language modules/features. It's very logical and simple. Basically the module allows you to have different names for all your configured languages per page. 1 Link to comment Share on other sites More sharing options...
dragan Posted July 30, 2013 Share Posted July 30, 2013 Wow, you guys are truly great. Thanks for your patience. It's all solved now. I can't believe how easy it all is now. I was basically starting with an older technique, switched to the new one, and there was still all kinds of legacy code here and there. Strange redirects, 404s etc. Remember that I owe you a beer if you should ever come to this neck of the woods... 1 Link to comment Share on other sites More sharing options...
Wanze Posted August 6, 2013 Share Posted August 6, 2013 Feature request: When creating a link in TinyMce in a language other than default, ProcessPageEditLink generates the url of the default language, not the "local" one. Would be nice if ProcessPageEditLink inserts the url based on the language of the field one is creating the link. I guess this could be a tricky one... 2 Link to comment Share on other sites More sharing options...
ryan Posted August 8, 2013 Author Share Posted August 8, 2013 That's an excellent suggestion. I'm honestly not yet sure how to implement it though. I've gone ahead and added a "data-language" attribute, with the language ID, to the LanguageSupport wrapper that goes around each multi-language field. The next step is to get the TinyMCE and CKEditor pwlink.js plugins to pull the language ID from the wrapper–this is the part I can't figure out yet. Once we've got that, the TinyMCE/CKEditor plugins can easily bundle it into the iframe/model request URL as a GET variable. Then the ProcessPageEditLink.module can detect and use it from there. 2 Link to comment Share on other sites More sharing options...
Wanze Posted August 8, 2013 Share Posted August 8, 2013 Nice, thanks ryan Another thing i noticed thought I don't know if intended this way: If I output the name of a page when another language than the default ist set, the name of the default language gets returned. Example: // Language is german, name of the page is artikel in german echo $page->name; // Returns articles (default language), not artikel Link to comment Share on other sites More sharing options...
ryan Posted August 8, 2013 Author Share Posted August 8, 2013 What you are looking for is probably $page->localName($user->language). The LanguageSupportPageNames module modifies the output of $page->path() / $page->url(), but not $page->name. That's because it's kind of a primary identifier for a page that needs to stay consistent at runtime regardless of language. 1 Link to comment Share on other sites More sharing options...
Wanze Posted August 8, 2013 Share Posted August 8, 2013 Of course... thanks ryan. Makes sense. I used localUrl already, it should have been clear that localName() exists too Pw rocks! 1 Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 Just implemented this on the site I am doing and I have to say that this is just pure awesomeness! Exactly the way I want things to work when it comes to languages. Thanks, Ryan, for understanding and paying attention to the importance of multi-language support for us poor souls that are not from English speaking nations. I do have one problem though that I wanted to ask the forum about. I have this loaded in my main.js to get the pin I want on my google map: var infoWindow = new google.maps.InfoWindow(); var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions); var image = { url: '../site/assets/files/1206/pin.png', size: new google.maps.Size(64, 75), origin: new google.maps.Point(0,0), anchor: new google.maps.Point(28, 76) }; var shadow = { url: '../site/assets/files/1206/shadow.png', size: new google.maps.Size(105, 52), origin: new google.maps.Point(0,0), anchor: new google.maps.Point(0, 56) }; Works great on my default page, but it won't load the pin (the map loads great apart from that) on the second language page. I recon it has to do with the links. Tried some variations but could not get it going (and I have to find some way to make it work on both pages). Any suggestions? Link to comment Share on other sites More sharing options...
dragan Posted August 15, 2013 Share Posted August 15, 2013 Try using absolute URLs url: 'http://www.mysite.com/site/assets/files/1206/pin.png', or url: '/site/assets/files/1206/pin.png', 2 Link to comment Share on other sites More sharing options...
ryan Posted August 15, 2013 Author Share Posted August 15, 2013 Dragan is right, it your relative URLs wouldn't work just because the path may be changing relative to the language. The fix is as simple as using an absolute path rather than a relative one. 1 Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 Yea, absolute worked (I only tried all kinds of internal ones). Makes for a little bit less portability, but if that is the way i have to go, it's certainly OK - thanks guys! Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 I have an additional question about this. There are some things I have to change manually. For instance i have a custom made Swedish php-function to produce the desired date format. On my English page, I need that function to be replaced with a standard English format. How do I make a simple check if the current language is English for instance (to be used in an if statement to decide which date function to use)? I should perhaps add that it is for use within a function. Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2013 Share Posted August 15, 2013 I have an additional question about this. There are some things I have to change manually. For instance i have a custom made Swedish php-function to produce the desired date format. On my English page, I need that function to be replaced with a standard English format. How do I make a simple check if the current language is English for instance (to be used in an if statement to decide which date function to use)? I should perhaps add that it is for use within a function. The user has the language set. if($user->language == "en") ... 1 Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2013 Share Posted August 15, 2013 You'll also find plenty of input on multilanguage in the multilanguage documentation: http://processwire.com/api/multi-language-support/multi-language-urls/ Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 The user has the language set. if($user->language == "en") ... Yea, that was the first thing I tried, but I get: Notice: Undefined variable: user Link to comment Share on other sites More sharing options...
Soma Posted August 15, 2013 Share Posted August 15, 2013 Within a function use wire("user"). 1 Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 Ah, that is surely the problem! Thanks, I thought direct calls to the API was the same. Will let you know after I test! Link to comment Share on other sites More sharing options...
NoDice Posted August 15, 2013 Share Posted August 15, 2013 Yea now it works (after correcting my code error)! I had to go with if (wire("user")->language->name and "english" though to get it to act differently between the languages (since i use "english" for my secondary language). Thanks a lot again Soma! Link to comment Share on other sites More sharing options...
Soma Posted September 12, 2013 Share Posted September 12, 2013 That's an excellent suggestion. I'm honestly not yet sure how to implement it though. I've gone ahead and added a "data-language" attribute, with the language ID, to the LanguageSupport wrapper that goes around each multi-language field. The next step is to get the TinyMCE and CKEditor pwlink.js plugins to pull the language ID from the wrapper–this is the part I can't figure out yet. Once we've got that, the TinyMCE/CKEditor plugins can easily bundle it into the iframe/model request URL as a GET variable. Then the ProcessPageEditLink.module can detect and use it from there. Ryan, this is a very important feature to complete the language support. I'm currently working on a multilanguage project that will maybe need to have links localized in TinyMCE. Can I somehow help with this? I'm not sure what you already have done, but will take a look. Any pointer would be greatly appreciated. Link to comment Share on other sites More sharing options...
Soma Posted September 12, 2013 Share Posted September 12, 2013 Me again. I glimpsed at what you already done with that "wrapper". I now got it working for TinyMCE links plugin. So it will create localized urls when selecting from the page tree. I had to modify a couple files to add a langID option to ProcessPageList and ProcessPageEditLink. Should I just make a pull request with those changes so you can look at and test? Edit: Pull Request done https://github.com/ryancramerdesign/ProcessWire/pull/241 3 Link to comment Share on other sites More sharing options...
masslevel Posted September 14, 2013 Share Posted September 14, 2013 Hello guys, this thread has already been proven extremely informative. Thank you for that. I have a quick question and I'm not sure how to approach it using LanguageSupportPageNames, LanguageSupportFields (latest dev version 2.3.4) - or if it's even possible. Scenario - Multiple languages (default, de, fr...) - PW Multi-Language Support (PageNames etc.) What If I want to create/publish a page only in DE language, and that page should not be available in the default language? It could also be a case of "slow on the uptake" on my part. So apology in advance ;-). Any feedback is much appreciated. Thank you! regards //symb Link to comment Share on other sites More sharing options...
ryan Posted September 15, 2013 Author Share Posted September 15, 2013 I now got it working for TinyMCE links plugin. So it will create localized urls when selecting from the page tree. Thanks for the PR Soma! I will pull this in within the next day or two and make any necessary updates to the CKEditor plugin as well. What If I want to create/publish a page only in DE language, and that page should not be available in the default language? Default language is required. But you could always add your own checkbox field to the page as a toggle to disable it. Your head.inc or _init.php or whatever your common initialization file is could check: if($page->disable_default_language && $user->language->isDefault()) throw new Wire404Exception(); You'd also have to consider it with navigation generation, perhaps skipping over pages that have the toggle set while in the default language, or adding it to your selectors when querying pages. Edit: you could also just choose to not use the default language at all. if($user->language->isDefault()) $user->language = $languages->get("en-us"); // or whatever you want your default to be 1 Link to comment Share on other sites More sharing options...
Soma Posted September 15, 2013 Share Posted September 15, 2013 You're welcome. Ryan, you just have to look at what you take from my PR, because I think you modified some of the files at the same time. Also you may have to check if the code really makes sense and maybe something missing an isset() or alike. I just done it real quick and only tested with multilanguage on. Link to comment Share on other sites More sharing options...
masslevel Posted September 15, 2013 Share Posted September 15, 2013 if($page->disable_default_language && $user->language->isDefault()) throw new Wire404Exception(); if($user->language->isDefault()) $user->language = $languages->get("en-us"); // or whatever you want your default to be Once again - simple and elegant. Thanks, Ryan! Awesome. I guess my mind is still living in a framework/CMS world where everything needs to be constrained and complicated. ProcessWire lets you breathe. 1 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