Jump to content

LanguageLocalizedURL


mcmorry

Recommended Posts

0.0.4 released.

I've updated the documentation. I hope that it's easy to understand and use it.

I'm sure that there is space for improvement and some bad English to fix. If you find something to change don't hesitate to tell me ;)

  • Like 1
Link to comment
Share on other sites

Great!! Everything is working very well on a fresh PW install with only this module activated. The navigation and all the links of the default site with the original code unchanged work very well.

Suggestions for the Docs:

  • instruction to check "Allow Url Segments" on the language template is missing.
  • would make sense to suggest to check "Hidden: Excluded from lists and searches" on the language pages.
  • Like 1
Link to comment
Share on other sites

I've been offline for the weekend since Friday, sorry to be stepping into the conversation late. I'll be happy to implement an unset function for url segments, but wondered if it should just unset, or should it also reindex the url segments that are remaining? For instance, if you have both urlSegment1 and urlSegment2 set, and you unset urlSegment1 should urlSegment2 take the place of urlSegment1?

  • Like 1
Link to comment
Share on other sites

Great!! Everything is working very well on a fresh PW install with only this module activated. The navigation and all the links of the default site with the original code unchanged work very well.

Suggestions for the Docs:

  • instruction to check "Allow Url Segments" on the language template is missing.
  • would make sense to suggest to check "Hidden: Excluded from lists and searches" on the language pages.

Thanks for testing it on default website. It's very good to know that it works without any problems.

About docs, you are right. It's better to include that two points. Thanks ;)

I've been offline for the weekend since Friday, sorry to be stepping into the conversation late. I'll be happy to implement an unset function for url segments, but wondered if it should just unset, or should it also reindex the url segments that are remaining? For instance, if you have both urlSegment1 and urlSegment2 set, and you unset urlSegment1 should urlSegment2 take the place of urlSegment1?

Hi Ryan,

I'm glad to hear that you can introduce this method :)

Yes it's much better to reindex the segments. In this way the code inside templates remains compatible with the standard functionalities.

Thanks again.

Link to comment
Share on other sites

Thanks Ryan. Yes reindex. I implemented a unset function in the WireInput to test this, and I get unexpected behavior if the page is a subpage which both use urlSegments. Not sure whats causing it , or if its the default behavior or not, I need to make some more tests. Maybe it's my code in the module causing it.

basic-page (urlSegments enabled)

Parent (basic-page)

Child (basic-page)

if on Child it will include it in segments.

/parent/child/segment1/

it will be

segment1 = child

segment2 = segment1

Link to comment
Share on other sites

Soma that's not the correct behavior. The segment of a page that actually exists should never be included as a urlSegment. urlSegments are just the extra segments in the URL that didn't resolve to a page. I'll add this unset function to the $input.

Link to comment
Share on other sites

I just updated the Input class so that you can now unset URL segments. Use the existing $input->setUrlSegment($n, $value); function, but specify null as the $value for the segment you want to unset. When you do that, it'll unset the segment and reindex. For instance, lets say you had page /about/products/a/b/c/ where /a/b/c/ are the URL segments 1, 2, 3. If you call $input->setUrlSegment(1, null); then /b/c/ would be segments 1, 2 (and no more 3).

  • Like 1
Link to comment
Share on other sites

mcmorry, the code I started for urlSegments remapping is completely wrong logik. Hope you get it.

I figured that you simply need to add a counter everytime a page is found, to then, after the foreach, unset them by this count.

Also I found that with this method you'd better remove urlSegments if the page requested was resolved without any segments. Or it will still have urlSegments from the language root page...

Let me know if I can help in anyway.

Link to comment
Share on other sites

Have you tried in deeper levels too? I can't get it to work with anything deeper than 1st level. like /en/template/page1/[s1]/[s2]

I can't solve it right now, too tired. :)

Edit:

I think found that the "$parent = $page" for temporary saving if page is not found is causing the issue. My bad, was my fault coding it this way. :)

Link to comment
Share on other sites

ok I pushed on develop.

I'm not sure if there are problems with pagenums. I didn't test it yet.

Edit: it works correctly with deeper levels. I simply remove from urlSettings the first key the same amount of parents.

Link to comment
Share on other sites

ok thanks for testing it. I'll update the documentation and merge to master.

Next step will be to automate the installation process (include modules, prepare templates and proxy pages) and automatically sync the proxy pages when a new language is added/removed in the settings.

I will create some issue on github so it will be easier to track the progress and to collaborate.

Link to comment
Share on other sites

Bug?? I was showing that it works!

edit: the image was to show that the segments are working well. What did you think was a bug? That there is one page with English name? If it's that, don't worry, that's the only one that I didn't define a Portuguese title :)

Link to comment
Share on other sites

:-[ ops...

I've seen in the url /segment1/segment2/segment3 that was reported below. And I thought that they was listed as pages. Sorry... too late.... better if I go to sleep now ;)

So, good to see that is working :)

Link to comment
Share on other sites

I wasn't clear enough.

To be clear now, the image is the result of this code

foreach ($input->urlSegments as $segment) {
echo "<h3>{$segment}</h3>";
}

added on top of the default site-map template

Link to comment
Share on other sites

I have beed reading this thread with much excitement as I am to start a site translation this month. It look awesome!! I am yet to test the plugin but was wondering if it's possible to have the following urls:

Mysite.com --- default language (Spanish)

Mysite.com/en --- for English

Mysite.com/pr --- for Portuguese

Is this possible? Is this even a good practice? The thing is the site is well ranked and languages are being added just now, so the main URL would not change and would respond to the default language.

Thanks to all the people contributing in this plugin!!

Link to comment
Share on other sites

Hi landitus,

I think that there is a problem in your case. Setting the default language to Spanish will create the homepage in Spanish, but ALL the other pages will be under /es folder.

I'll check if there is a way to add an option in the settings to have the default language without the language sub-folder.

Another thing that in any case you should consider, is to avoid duplicated contents. So if you add a language, prepare all the translations before to link them.

Link to comment
Share on other sites

I see another problem. for Portuguese should be pt and not pr ;)

I'll check if there is a way to add an option in the settings to have the default language without the language sub-folder.

I also think think it would be nice to have this option. Hope there is a way.

Link to comment
Share on other sites

Good, my mistake diogo! :)

Thanks for the replies. I think that this approach would be common and thought it can be solved by following the subdomain and suffix technique; there's the belief that the suffix directory is the best for multilingual.

I am still deciding this myself but look forward to any suggestions on this subject!

Link to comment
Share on other sites

Could landitus' method work if you made the home page (or any page lacking a language marker) redirect to the same page with the language marker added? So, given this structure...

Mysite.com/pt = Portuguese home page

Mysite.com/pt/contact = Portuguese contact page

Mysite.com/es = Spanish home page

etc...

You'd do this...

Mysite.com --redirect--> Mysite.com/es

Mysite.com/contact --redirect--> Mysite.com/es/contact

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...