Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to keep the $language variable between requests? #19

Closed
timokleemann opened this issue Dec 12, 2017 · 4 comments
Closed

How to keep the $language variable between requests? #19

timokleemann opened this issue Dec 12, 2017 · 4 comments
Assignees
Milestone

Comments

@timokleemann
Copy link

Hi,

I am using the 1.X release and it works really well for me, except that I find it difficult to keep the $language variable between requests. What is the best way to keep it? It would be nice to have URLs like:

I managed to set it up using the URL router extension, however it wants me to define a route for every single page I've got. With this project that means setting up more than 600 routes.

What's the best way to deal with this?

@twiro
Copy link
Owner

twiro commented Dec 12, 2017

Hey Timo,

What's the best way to deal with this?

In version 1 you had to take care of your url-routing yourself, version 2 integrates the above-mentioned way of setting the language as url-param automatically via htaccess-rules.

So if you don't care about translated page-handles version 2 will do everything you need out of the box – It's mostly finished and I'm already using it on several live websites, I just haven't released it yet due to some missing parts in the documentation. I hope to give it the last polish needed before the year ends but I'm not sure if I'll really find the time – documentation always is the hardest part ;)

I strongly recommend switching to version 2 and following the already finished chapters of the documentation.

@twiro twiro self-assigned this Dec 12, 2017
@twiro twiro added this to the 2.0.0 milestone Dec 12, 2017
@twiro
Copy link
Owner

twiro commented Dec 12, 2017

If you do need translated page-handles then it's a different story… I usually care about fully translated urls and therefore need a solution to translate page-names/handles also.

But as most of my projects consist of less than 20 symphony-pages I currently combine multilingual 2.0 with jens scherbl's routing extension and a custom datasource that contains all multilingual page names (for frontend/navigation-stuff). That works really well, but I wouldn't want to set this up for 600 pages ;)

I also already combined multilingual 2.0 with page_lhandles in one project, but that means installing all these multilingual-extension-dependencies ( languages, frontend-localisation, etc.) just to get the pages translated. Not a very clean approach and my aim with multilingual 2.0 was to have an out-of-the-box-multilingual-solution that doesn't need a whole couple of extensions to get things running. Translating pages/handles is the missing link – I'm aware of that and hope to find a good solution in the future. But til then this part of a multilingual website has to get solved otherwise…

@twiro
Copy link
Owner

twiro commented Dec 12, 2017

But as most of my projects consist of less than 20 symphony-pages I currently combine multilingual 2.0 with jens scherbl's routing extension and a custom datasource that contains all multilingual page names (for frontend/navigation-stuff). That works really well, but I wouldn't want to set this up for 600 pages ;)

To demonstrate how this looks like – this is an example of my routes.xml:

<?xml version="1.0" encoding="UTF-8"?>
<routes>

	<!-- 1) HOME -->
	<route from="/" to="/home/" />

	<!-- 2) PROJEKTE -->
	<route from="/projekte/" to="/projekte/" />
	<route from="/progetti/" to="/projekte/" />
	<route from="/projects/" to="/projekte/" />
	<route from="/projekte/:entry/" to="/projekte/:entry/" />
	<route from="/progetti/:entry/" to="/projekte/:entry/" />
	<route from="/projects/:entry/" to="/projekte/:entry/" />
	
	<!-- 3) UNTERNEHMEN -->
	<route from="/unternehmen/" to="/unternehmen/" />
	<route from="/azienda/" to="/unternehmen/" />
	<route from="/company/" to="/unternehmen/" />
	<route from="/unternehmen/:entry/" to="/unternehmen/:entry/" />
	<route from="/azienda/:entry/" to="/unternehmen/:entry/" />
	<route from="/company/:entry/" to="/unternehmen/:entry/" />
	
	<!-- 4) AKTUELLES -->
	<route from="/aktuelles/" to="/aktuelles/" />
	<route from="/notizie/" to="/aktuelles/" />
	<route from="/news/" to="/aktuelles/" />
	<route from="/aktuelles/:entry/" to="/aktuelles/:entry/" />
	<route from="/notizie/:entry/" to="/aktuelles/:entry/" />
	<route from="/news/:entry/" to="/aktuelles/:entry/" />
	
	<!-- 5) KONTAKT -->
	<route from="/kontakt/" to="/kontakt/" />
	<route from="/contatto/" to="/kontakt/" />
	<route from="/contact/" to="/kontakt/" />
	
	<!-- 6) ID -->
	<route from="/id/:entry/" to="/id/:entry" />
	
	<!-- 7) MAINTENANCE -->
	<route from="/maintenance/" to="/maintenance" />

</routes>

And this is my pages.xml that I include as a custom datsource:

<?xml version="1.0" encoding="UTF-8"?>
<pages>
	<page handle="home" id="1">
		<item lang="de" handle="home">Home</item>
		<item lang="it" handle="home">Home</item>
		<item lang="en" handle="home">Home</item>
	</page>
	<page handle="projekte" id="2">
		<item lang="de" handle="projekte">Projekte</item>
		<item lang="it" handle="progetti">Progetti</item>
		<item lang="en" handle="projects">Projects</item>
	</page>
	<page handle="unternehmen" id="3">
		<item lang="de" handle="unternehmen">Unternehmen</item>
		<item lang="it" handle="azienda">Azienda</item>
		<item lang="en" handle="company">Company</item>
	</page>
	<page handle="aktuelles" id="4">
		<item lang="de" handle="aktuelles">Aktuelles</item>
		<item lang="it" handle="notizie">Notizie</item>
		<item lang="en" handle="news">News</item>
	</page>
	<page handle="kontakt" id="5">
		<item lang="de" handle="kontakt">Kontakt</item>
		<item lang="it" handle="contatto">Contatto</item>
		<item lang="en" handle="contact">Contact</item>
	</page>
</pages>

If you don't have too many pages this is a really clean setup in my eyes!

@timokleemann
Copy link
Author

Thanks, everything works now! I didn't know version 2.0 was production ready. But it seems it is. The routing and everything works as expected and it was very easy to set up! Thankfully, I don't need localized page handles for now. Thanks for developing this extension, will probably use it on a number of projects.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants