This sounds like you need to implement some kind of router.
I've faced it myself and this is how I made it work quite good:
Some router class parses the URL. It explodes URL parts (/en/controller/action/param1/paramval1/
) into pieces. It determines language code (default if not provided), controller, action, etc.
Router also provides information (controller, action names, parameters) to other parts of the system, although you may implement special class for that purpose (eg. Request).
Now different parts of the system have access to given information via Router or Request class. From here on, it should be easy to implement multilangual site.
Once again, the important part is mapping URL to controller and action. Definitely, if you don't want URL like /controller/action/parameter1
, you should have some mapping table (XML document / database table) that maps a stub (page short tag) to controller and action. It is the router that reads this table and determines controller, action and other parameters based on the given rules.
Hope I didn't complicate too much :)
Update:
As for myself, I've implemented mapping with XML file. Let me explain further: router takes care of resolving the URL. Normally, your URL would contain the controller and action name (in your case, pages is the controller, view is the action).
Now in your case, you want just a stub, so router must somehow obtain the information about which controller and action is being called. That is the purpose of mapping, to map the stub to appropriate controller and action.
I've implemeted this as static routes, written manually into XML file, but you could for example use some kind of plugin class that checks if stub actually relates to a page. If it doesn't, that can mean two things: it is a controller or request is invalid.
Let me talk further about collisions: if stub is the same as the name of any controller, you have a collision. Should you render a page with a given stub, or call the controller? That has to resolved somehow, perhaps you can programatically restrict user to have a page with that kind of stubs.
Also, next time you dive into application development with PHP, I'd recommend you using some well-known PHP framework (if you don't already, ofc.), e.g. Zend, Kohana or CodeIgniter. They all provide router and many other components that make developing applications much easier, faster and more secure.