Jump to content

LanguageLocalizedURL


mcmorry

Recommended Posts

As much information possible to reproduce would be helpful, because pagination works fine here with whatever code. More code, module settings, setup, versions, PW in a subfolder, other modules that does something on urls or pagination?

  • Like 1
Link to comment
Share on other sites

Hi Soma,

First of all, thanks for helping to build and support this module. This is my preferred way to build multilingual sites and I hope to use this module in a lot of projects.

I am testing this module on two different installations.

The first installation has just been upgraded from 2.2.0.1 to 2.2.9. It has quite a few modules installed.

The second installation is a test site I am using to play with the module. I recently upgraded it from 2.2.6 to 2.2.9. It is a pretty clean install and only has one extra module installed - an AdminHotKeys plugin - not sure who developed that :)

They both have the latest module LanguageLocalizedURL installed 0.1.0

Both are setup in the root folder.

On my test installation I have just setup a very basic pagination example as shown here

http://processwire.com/api/modules/markup-pager-nav/

$results = $pages->find("id>1, limit=10, sort=title");
echo $results->render();

and it also has the same issues.

Let me know if you need further information.

  • Like 1
Link to comment
Share on other sites

Just to make sure some more random thoughts. Any more infos would be helpful. What are the module setting?

Have you enabled "Allow Page Numbers" in the template where you want to do pagination?

Also try this code along with the pagination code:

if($input->pageNum){
 echo "<br/>pageNum: $input->pageNum";
}

Any Infos on what doesn't work and what it exactly does would also be helpful. Generally any code in templates can maybe be the problem so I'm a little lost here because it works fine here.

The url landitus posted is wierd and can't think of why it would be /page2/page2 as this is clearly wrong.

Link to comment
Share on other sites

The template has "Allow Page Numbers?" enabled.

I have tried it with all the different module options. And I have tested with "Page ID prefix" and "Parent ID prefix" enabled and disabled.

I just setup another test site, completely from scratch. Latest PW, only the LanguageLocalizedURL.module installed, default template, and with the basic pagination example. It still does not work.

If I uninstall the LanguageLocalizedURL module, the pagination works.

This is the debug information for the page with pagination - https://gist.github.com/ccd6e536289e649c502a

Hope that helps. I can also send you a site profile of my local test installation.

Link to comment
Share on other sites

I will try later with a fresh installation, just to make sure.

BTW what does my code example output?

The admin debug output doesn't help much. Any errors? What are the url's and what does not work and does it show?

Link to comment
Share on other sites

I just setup a complete new install with this module, and it also didn't work with pagination. I only enabled urlSegments to the proxy template (as in manual) and as soon as I enabled page numbers also it started working again.

Can you check if you have url segements and page numbers enabled on the language proxy template.

Works all fine here.

  • Like 2
Link to comment
Share on other sites

As mentioned in the readme, this module does not work too well when you have lots of pages. I have been testing on a site with quite a few pages - there are over 150 pages used for locations, and another 120 pages used for categories. The affect on performance is very noticeable. Even when using ids on pages and parents.

I’ve been trying to work out how to change the module so that it ignores certain templates or pages from being translated? For example, I don’t really need to have the categories and location names translated. Do you think this might help with performance? Any tips on where to add the ignore selector?

On a side note, while my preferred solution would be to have proper urls for each language, (it’s much better for users and looks nicer), from an SEO point of view it might not be as important as I first thought. According to this post on Googles webmaster blog, it seems like so long as you indicate the current language in the url (which is solved by appending the /de/ or /en/) then you should be ok.

http://googlewebmast...l-websites.html

Link to comment
Share on other sites

I haven't tested with more than a couple pages yet, and only built 1 simple 30~ pages website and haven't noticed any big slowdowns. Don't know if there's anything else than the search of pages that slows it down as there's quite some stuff happening on parsing urls.

But of course the brute force method isn't that optimized for large sites as mentioned in the readme. Not sure how it could be improved without building a lot additional stuff like an index table. There would have to be some tests and experiments what would really help and I have no need for it ATM. Maybe someone else experienced can have a look.

Link to comment
Share on other sites

Also what would help is to see your setup. Are those pages locations and categories in one folder which is hidden? How much is the slowdown and how do you recognize it? What version of PW?

I have a hard time believing that ~300 pages already is noticable. Though It maybe has to do with the render() method in the proxy gateway template which seem to cause the page getting rendered 2 times.

Still not sure about many parts of the module, that's why it is stil considered experimental and I wouldn't recommend using it in larger and serious projects and be somewhat cautious about it's drawbacks. The module also hooks into the tinymce text fields to parse and replace urls which obviously gets in conflict with the Page Link Abstractor module by ryan which also does parse the same urls. There's just some edge cases where there can happen things you might not aware yet.

Though PW is enough flexible and powerful to easily switch to another approach, but could hurt the projects urls and seo. At the end, only if people are using and testing it, it can be improved.

  • Like 1
Link to comment
Share on other sites

As mentioned in the readme, this module does not work too well when you have lots of pages. I have been testing on a site with quite a few pages - there are over 150 pages used for locations, and another 120 pages used for categories. The affect on performance is very noticeable. Even when using ids on pages and parents.

If you would let us know what exactly your doing codewise with you categories and locations it would help finding what's going on.

I have tested a little more and I have 800 pages and when going to a page that's on position 800 it has to parse all page 800 to that point, but when prefix id's is enabled it does a good job. Execution times a slightly higher, as it is without the module enabled. And I'm talking about ~0.1 seconds. But it all depends how many heavy code you are performing.

SInce I'm not sure in your case if it's the finding pages or generating urls that causing the slowdown, I'm curious to know exactly what your doing in your templates.

I’ve been trying to work out how to change the module so that it ignores certain templates or pages from being translated? For example, I don’t really need to have the categories and location names translated. Do you think this might help with performance? Any tips on where to add the ignore selector?

Not really a solution since I don't know yet what's causing the problem. But with id's enabled it's a lot better optimized as if I would use a index table to get pages quicker. Again I can image it's something different, as I have no problems in my testcase.

  • Like 1
Link to comment
Share on other sites

Thanks again Soma. You are correct, it was a bit of code that was causing the slowdown - a selector + array manipulation that I was using to get the most popular features . Once I removed this bit of code it went from over 6 seconds to under 1.

Just to compare with the module removed and using the code the db queries takes around 1.4 seconds.

removing both the code and the module, the queries take 0.8 secs. It was probably a very inefficient bit of code anyways.

Thanks for testing, it's good to know that this solution can scale up to that level

I will send you a link to the development version - you might find it interesting as it's a playground finder for Zurich :)

Link to comment
Share on other sites

  • 4 weeks later...

Hi,

I've a little problem with this module.

Works very well but..

I've two languages now.. IT and EN. IT is the default.

With Disable sub-folder for default language checked:

example.com -> it, works

example.com/it/ -> it, not works, ok

example.com/en/ -> en, not works, not ok

example.com/prodotti -> it, not works, not ok

example.com/en/products -> en, not works, not ok

...

If Disable sub-folder for default language unchecked:

example.com -> it, works

example.com/it/ -> it, not works, ok

example.com/en/ -> en, works, ok

example.com/prodotti -> it, works, ok

example.com/it/prodotti -> it, not works, ok

example.com/en/products -> en, works, ok

but, obviously, all the IT links created from the system has prefix "it" (not works).

Forgot something?

Thanks,

Marco

Link to comment
Share on other sites

moreweb, I don't know since I don't see how you set everything up. And without specific errors or more details what doesn't work I can't help. I can't do much with things like: "example.com/en/ -> en, not works, not ok"

All I can say for now is it works fine, as it should. I can switch it on and off and everything works.

Link to comment
Share on other sites

Hi Soma,

sorry, I think that it can be e general configuration error.

No logs or other errors, only a general 404 when I disable sub-folder.

All debug options enabled.

It not works fine for me: with Disable sub-folder for default language unchecked it works when I write URL manually less /it/, when it is checked it not works at all.

Link to comment
Share on other sites

Hi mcmorry,

I've read the howto and the thread..

Point 3 in howto:

Create below the root page, one page per each language (en, it, fr, ...) (for the default language too if you don't want disable it in the settings) using that template.

I want disable it for the default language -> so I don't create "it" page.

With "it" page it works.

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hey Soma, great module! I'm trying to use it, but get the same problem nikola did: Unknown Selector operator: '' -- was your selector value properly escaped?

It happens only on the root page.. I've reproduced it sucessfully on a clean install - it occurs to me when using a textAreaLanguage - whenever I change the default language's text, it throws an error! If I leave the default language blank, it saves just fine.

Update:

Okaaaaaayyy weird things are happening... So I've been experimenting, and the module tries to do some url rewriting, mapping a /page toa /lang/page, depending on which the textAreaLanguage's languages we are writing. On the standard Body (made to be a textAreaLAnguage) a "<a href='/templates/'>" maps to a "<a href='/pt/templates/'>", but a "<a href='./templates/'>" (notice the extra dot) throws the infamous error. Weirder still, a new "new_body" field (plain textArea field, no formatting) accepts no url format at all, not /pt/templates, nor /templates, neither ./templates....

Link to comment
Share on other sites

Well, this stopped for me when using tinyMCE, it happened only when using plain text, with no formatting... Sorry for the delay responding, I came across this issue during a project, one that ended up being a pain in the arse... And one that yielded nothing - clients from hell :P

Clarifying - this is a problem specific to a plain (no formatting) body (the "original") textarealanguage field. any other textarealanguage (not the Body) works ok.

Anyhow, a different issue made me think of a possible feature - control over the field lang substitution behaviour.

When a field is called via the selectors, it is automatically translated to the other available languages, if it is empty.(right?) This may not be the desired behaviour (as when doing something like the echo (headline || title) behaviour ) is there a way to control this?

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...