In this recipe, we will learn how to internationalize text that is located in our application views, and have that content ready for translation.
To go through this recipe, we need some data to work with. Create a table named articles
with the following SQL statement:
CREATE TABLE `articles`( `id` INT UNSIGNED AUTO_INCREMENT NOT NULL, `title` VARCHAR(255) NOT NULL, `body` TEXT NOT NULL, `created` DATETIME NOT NULL, `modified` DATETIME NOT NULL, PRIMARY KEY(`id`) );
Now add some sample data to this table with the following statement:
INSERT INTO `articles`(`title`, `body`, `created`, `modified`) VALUES ('First Article', 'Body for first article', NOW(), NOW()), ('Second Article', 'Body for second article', NOW(), NOW()), ('Third Article', 'Body for third article', NOW(), NOW());
Create the controller for this table in a file named articles_controller.php
and place it in your app/controllers
folder, with the following contents:
<?php...