Adding a New Translation to VCalendar in PHP
- Copy the file "en.txt" into a new file named as <2 char language code>.txt , (for example fr.txt). See Appendix 1.
- Translate all values in the new file to the desired language.
- In Common.php add line 24 with the translated language, for example for French:
$CCSLocales->AddLocale("fr", Array("fr", "FR", ...
See Appendices 2 and 3.
- Translating button images.
Translate images in each style folder (Basic, Blueprint, CoffeeBreak etc.), under the 'images' sub-folder. Add new sub-folder with the desired language code, for example "fr". You can copy all images from 'en' sub-folder, open buttons in a graphic editor and change the button text.
Note: To use simple buttons change the HTML code in the *.html files the same way as the following example for the 'Go' button:
from
<input type="image" border="0" value="Submit" src="Styles/{CCS_Style}/Images/{res:CCS_LanguageID}/ButtonGo.gif">
to
<input type="submit" border="0" value="{res:Go}" name="Go">
- Database changes.
- Update the record into the config table with id=7 (default_language) to add new locale to the config_listbox field.
This field's value is used to build the Locale lisboxes. See Appendix 4.
- Add data in new languages to the following tables (xxxxx_langs): categories_langs, config_langs, contents_langs, custom_fields_langs, permissions_langs, email_templates_lang. See Appendix 5.
Appendix 1. Languages - ISO 639-1 alpha-2 codes
"af"="Afrikaans"
"sq"="Albanian"
"ar"="Arabic"
"hy"="Armenian"
"eu"="Basque"
"be"="Belarusian"
"bg"="Bulgarian"
"ca"="Catalan"
"zh"="Chinese"
"hr"="Croatian"
"cs"="Czech"
"da"="Danish"
"nl"="Dutch"
"en"="English"
"et"="Estonian"
"fo"="Faroese"
"fi"="Finnish"
"fr"="French"
"de"="German"
"el"="Greek"
"he"="Hebrew"
"hi"="Hindi"
"hu"="Hungarian"
"is"="Icelandic"
"id"="Indonesian"
"it"="Italian"
"ja"="Japanese"
"ko"="Korean"
"lv"="Latvian"
"lt"="Lithuanian"
"mk"="Macedonian"
"ms"="Malay"
"mr"="Marathi"
"nb"="Norwegian (Bokm+?l)"
"nn"="Norwegian (Nynorsk)"
"fa"="Persian"
"pl"="Polish"
"pt"="Portuguese"
"ro"="Romanian"
"ru"="Russian"
"sa"="Sanskrit"
"sk"="Slovak"
"sl"="Slovenian"
"es"="Spanish"
"sw"="Swahili"
"sv"="Swedish"
"ta"="Tamil"
"tt"="Tatar"
"th"="Thai"
"tr"="Turkish"
"uk"="Ukrainian"
"ur"="Urdu"
"vi"="Vietnamese"
Appendix 2. Adding the language parameters into Common.php
For French the line whould look like the following:
$CCSLocales->AddLocale("fr", Array("fr", "FR", array(1, 0, ""), 2, ",", " ", array("janvier", "f?vrier", "mars", "avril", "mai", "juin", "juillet", "ao?t", "septembre", "octobre", "novembre", "d?cembre"), array("janv.", "f?vr.", "mars", "avr.", "mai", "juin", "juil.", "ao?t", "sept.", "oct.", "nov.", "d?c."), array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"), array("dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."), array("D", "L", "M", "M", "J", "V", "S"), array("dd", "/", "mm", "/", "yyyy"), array("dddd", " ", "d", " ", "mmmm", " ", "yyyy"), array("HH", ":", "nn"), array("HH", ":", "nn", ":", "ss"), "", "", 1, false, "", "windows-1252", "CP1252"));
Appendix 3
A line consists of the folloiwng parameters:
$CCSLocales->AddLocale(
"fr",
Array("fr",
"FR",
array(1, 0, ""),
2,
",",
" ",
array("janvier", "fevrier", "mars", "avril", "mai", "juin", "juillet", "aout",
"septembre", "octobre", "novembre", "decembre"),
array("janv.", "fevr.", "mars", "avr.", "mai", "juin", "juil.", "aout", "sept.",
"oct.", "nov.", "dec."),
array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"),
array("dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam."),
array("D", "L", "M", "M", "J", "V", "S"),
array("dd", "/", "mm", "/", "yyyy"),
array("dddd", " ", "d", " ", "mmmm", " ", "yyyy"),
array("HH", ":", "nn"),
array("HH", ":", "nn", ":", "ss"),
"",
"",
1,
false,
"",
"windows-1252",
"CP1252"));
Formatting the language parameter line (in Common.php)
- 2 symbols of a language code (e.g. "fr") with a parameter array
- 2 symbols of a language code (e.g. "fr")
- 2 symbols of a country code (e.g. "FR")
- Boolean Format - boolean array (array(1, 0, "") or array("Oui", "No", ""));
- Decimal Digits;
- Decimal Separator;
- Group Separator;
- Month names (e.g. array("janvier", "fevrier",... );
- Short month names (e.g. array("janv.", "fevr.",... );
- Weekday names;
- Short weekday names;
- Weekday Narrow Names;
- Date display format (sample: 10/15/2006);
- Expanded date display format (sample: dimanche, 10 mars 2006);
- Time display format (sample: 10:15);
- Expanded time display format (e.g. 10:15:22);
- AM Designator (e.g. "", "AM");
- PM Designator;
- First Week Day (0-Sunday, 1-Monday);
- Boolean, Override Number Formats;
- PHP Locale;
- HTML Encoding;
- PHP Encoding;
Appendix 4. Basic SQL for adding a new locale
Let's use French as an example. Add 'fr;French' into table 'config'.
-- Adding a new language into table config
UPDATE config SET config_listbox = 'en;English;ru;Russian;fr;French' WHERE config_id=7;
Appendix 5. Basic SQL for adding a new translation, for example French.
Change 'fr' to the translated language code, and translate all the text.
-- SQL for categories
INSERT INTO categories_langs (category_id, language_id, category_name)
VALUES (1, 'fr', 'Main category');
-- SQL for config
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',3,'Calendar Snapshot mode', 'None;Don\'t show at all;Current;Show current month;
Selected;Show selected month');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',4,'Allow users to select a style', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',5,'Allow users to select a language', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',6,'Default Style','Basic;Basic;Blueprint;Blueprint;CoffeeBreak;CoffeeBreak;
Compact;Compact;GreenApple;
GreenApple;Innovation;Innovation;None;None;Pine;Pine;SandBeach;SandBeach;School;
School');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',7,'Default Language', 'en;English;ru;Russian;fr;French');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',8,'Menu type', 'None;None;Vertical;Vertical;Horizontal;Horizontal');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',9,'Page header', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',10,'Page footer', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',11,'Registration type','0;Disable registration;1;Registration without a
confirmation;4;New registration confirmed by E-Mail;8;New user addition requires
the administrator approval');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',12,'E-Mail to be shown in the From field', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',13,'SMTP Server name', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',14,'SMTP Server port', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',15,'Display the week icon in the year calendar', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',16,'Show Calendar Snapshot in views', '2;Monthly, Weekly, Daily;4;Weekly,
Daily');
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',17,'Display the week icon in the Calendar Snapshot', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',18,'Open the pop-up window for the events', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',19,'Display the navigator in the Calendar Snapshot', NULL);
INSERT INTO `config_langs` (`language_id`, `config_id`, `config_desc`, `config_listbox`)
VALUES
('en',20,'Time Format', '1;Predefined (depends from locale);2;Military (14:20);3;
US Standard (2:20 PM)');
-- SQL for Content
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(1,'fr','Displayed for the user after registration if confiramtion by E-Mail
is required','<h3>{user_login}</h3>\r\n<h4>Thank you for your
registaration.</h4>\r\n<p>You should receive confirmation instructions
by email shortly.</p>\r\n<p>Email was sent to {user_email}</p>');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(2,'fr','Displayed after registration if new user need admin approval',
'<h3>{user_login}</h3>\r\n<h4>Thank you for your registaration.
</h4>\r\n<h5>Your account must be approved by Administrator.</h5>');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(3,'fr','Displayed after registration if confirmation isn\'t required',
'<h3>{user_login}</h3>\r\n<h4>Thank you for your registaration.
</h4>');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(4,'fr','Displayed after the changing password','<h3>{user_login}</h3>\r\n
<p>Your password was changed successfully.</p>\r\n<p>
<a href=\"profile.php\">Back to profile</a></p>');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(5,'fr','Displayed for the user after verification','<h3>{user_login}
</h3>\r\n<h2>Your account is now active.</h2>\r\n');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(6,'fr','Displayed after the new password was sent','<h2>Email was sent
</h2><p>If you supplied the correct username or email address for
your account, the confirmation will be sent to the specified email address.
</p><p>Please check your mailbox.</p><a href=".\"
>Back to main page</a>.</p>');
INSERT INTO `contents_langs` (`content_id`, `language_id`, `content_desc`,content_value)
VALUES
(7,'fr','Displayed in the lost pasword page','<h2>Welcome, {user_login}
</h2><p>You may now change your password.');
-- SQL for Custom fields
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',1,'Location');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',2,'Cost');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',3,'URL');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',4,'TextBox 1');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',5,'TextBox 2');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',6,'TextBox 3');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',7,'TextArea 1');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',8,'TextArea 2');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',9,'TextArea 3');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',10,'CheckBox 1');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',11,'CheckBox 2');
INSERT INTO `custom_fields_langs` (`language_id`, `field_id`, `field_label`) VALUES
('fr',12,'CheckBox 3');
-- SQL for the Permissions
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (1,'fr','Who can add new events');
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (2,'fr','Who can UPDATE public events');
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (3,'fr','Who can DELETE public events');
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (4,'fr','Who can READ private events');
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (5,'fr','Who can UPDATE private events');
INSERT INTO `permissions_langs` (`permission_id`, `language_id`, `permission_desc`)
VALUES (6,'fr','Who can DELETE private events');
-- SQL for the Email Templates
INSERT INTO email_templates_lang (language_id,email_template_id,email_template_desc,
email_template_subject,email_template_body)
VALUES ('fr',1,'Confirmation message sent after registration.<br>Use
predefined tags:<br> {user_login} for login,<br>{user_email} for
user e-mail, <br>{date_time} for registration date,<br>{activate_url}
for activation URL.','confirmation message','Welcome {user_login},\r\nOn
{date_time} we\'ve received a request of registration to our online calendar for
{user_email} email address.\r\nIf you want to confirm the registration, visit
{activate_url} page.\r\n\r\nIf you received this email as an error, ignore and
delete it.\r\n\r\nThis registration will expire in 24 hours.');
INSERT INTO email_templates_lang (language_id,email_template_id,
email_template_desc,email_template_subject,email_template_body)
VALUES ('fr',2,'Message sent after the administrator approval. <br>Use
the predefined tags:<br> {user_login} as login,<br>{site_url} as site
URL.','Your account was approved','Welcome {user_login},\r\n\r\nYour account
was approved by the administrator\r\n\r\nLink: {site_url}.');
INSERT INTO email_templates_lang (language_id,email_template_id,email_template_desc,
email_template_subject,email_template_body)
VALUES ('fr',3,'Email sent to users who forgot password<br>
Use predefined tags:<br>{activate_url} for activation URL.',
'Forgot password','Someone (presumably you) requested a password change.
If this was not you, ignore this message, your data will be left unchanged.
\r\n\r\nOtherwise, please visit the following URL to change your password:
\r\n\r\n {activate_url}');
|