Hello,
I'm building a sort of CMS that will be used to publish German, Dutch, Spanish and English content. I have found some information on localization but it only covers how to change the language for certain titles. But what I need is to determine which language the user is requesting.
For example, if I have a user that is visiting this url: domain.com/de/webpages/email, then I need to know that he is requesting the "de" or german so that I can go to the database and fetch the german contents to fill this page with.
It's not only about changing titles like Name to Naam or whatever it is in German. It's about knowing what language to search for in the database.
How can this be done?
Thanks.
Update: I just found getLocaleFromUrl in the API. would this work if I put it in every place that I would want to fill in with different localized text from the DB?
Update: Params show [lang]. I found part of the answer. However, how can I go about requesting the right information from the database? I will be creating a table with each row containing a piece of text, marked by a column named lang, which indicates which language the text is in.
I wrote time ago an example about i18n to display fields for various locales.
Let's say that I have a table (by example 'page') with 'en_title' and 'de_title' columns. Now with
$Page->get('title');
depending on your locale will output en_title or de_title
Hi Edward,
First of all welcome to the Akelos community :)
Akelos routes might be the solution for you problem.
For example, using routes you don't really need to add webpages to your URL if that is the default action. You can use something like thi in your config/routes.php file
$Map->connect('/:action/schedules/:period', array('controller' => 'webpages'),array('period'=>'/(firstyear|secondyear)/'));
$Map->connect('/:action/:id', array('controller' => 'webpages', 'action' => 'index'));
$Map->connect('/', array('controller' => 'webpages', 'action' => 'index'));
Have a look into the routes wiki page for more information and into Routes unit tests if you need more usage examples.
Hello bermi,
Thanks. This is my first Akelos webapp.
I can see how routing works, but that would only help the users to not have to type in a long url. However, what I'm trying to find out is how to structure my templates.
I know that my CMS will need to have a listing of all the webpages so that when an admin logs in, he can see all the pages, choose one, and edit the page for both localization and i18n. So for example, if there is a paragraph that explains how to apply for an exemption, the admin should be able to log in, go to the english page, change it accordingly, then click on a German flag for example, then change it for the german students, and then press save. That is my goal.
My website will have different sections of course. Like Bachelors and masters. Should these be controllers?
I can't quite figure out what should be a controller and what should be a template because if I make Bachelors a controller, then any section of the website that is unrelated (Bachelors and Masters) would need to be a seperate controller. But if I unite them (both in a webpages controller), then I cannot assign any other templates except for Bachelors and Masters. And this is a problem because Bachelors section has subpages, as well as the MAsters section.
I understood the first response, how to retrieve a multilingual title. Now I need to go further than that. The pages I will be creating will have multilingual text everywhere, so I can see that I will be writing a lot of variables to extract the info from the DB for each dedicated language requested by the user.
Is there any info where I can find how to do this? So far I have found symfony to have a page dedicated to this. So I'm trying to translate this to akelos. It's here: http://www.symfony-project.com/book/1_0/13-I18n-and-L10n I would like to know what the techniques are to setup a database and controllers and templates to get this running. I want to stick to Akelos, so I'll keep searching.
I'm new at this btw. Thanks for the help.
I would better have a courses_controller for showing/managing Bachelor and Master models. You can use single table inheritance (see inline docs at lib/AkActiveRecord.php) and create a Course model and a courses table, including a type column for storing the course type. Then Bachelor and Master should extend the model Course.
I would move static content to the website_controller and use an action for each static page.
You can create multilingual columns prefixing the column name with and asterisk like in this example:
<?php
class CourseInstaller extends AkInstaller
{
function up_1()
{
$this->createTable('courses', '
id,
type,
*description,
starts_on,
ends_on,
location
');
}
function down_1()
{
$this->dropTable('courses');
}
}
?>
If you run this migration and your application is configured to work in en,es,de,fr locales, these columns will be created automatically by the migration
Then whenever you want to create a view for managing those fields you can use the column name straight away or this format:
<input type="text" name="course[description][es]" />
<input type="text" name="course[description][en]" />
…
And set the course details as normal using
$Model->setAttributes($this->params['course'])
Remember to include the model you'll use in the course_controller by setting
var $models = 'course,bachelor,master';
or using
Ak::import('course,bachelor,master');
at the top of your controller.
BTW, you should join #akelos at irc.freenode.net, the is already a nice CMS on the go that might suit your needs :)
1 to 8 of 8