Annotation of /mambo/branches/4.6/administrator/components/com_languages/views/edit.view.php
Parent Directory
|
Revision Log
Revision 1680 - (view) (download)
| 1 : | elpie | 971 | <?php |
| 2 : | /** | ||
| 3 : | * @package Mambo | ||
| 4 : | * @subpackage Languages | ||
| 5 : | ocs_cms | 1396 | * @author Mambo Foundation Inc see README.php |
| 6 : | * @copyright Mambo Foundation Inc. | ||
| 7 : | * See COPYRIGHT.php for copyright notices and details. | ||
| 8 : | * @license GNU/GPL Version 2, see LICENSE.php | ||
| 9 : | * Mambo is free software; you can redistribute it and/or | ||
| 10 : | * modify it under the terms of the GNU General Public License | ||
| 11 : | * as published by the Free Software Foundation; version 2 of the License. | ||
| 12 : | */ | ||
| 13 : | |||
| 14 : | elpie | 971 | defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); |
| 15 : | class editView extends View | ||
| 16 : | { | ||
| 17 : | function render(&$renderer, &$request) | ||
| 18 : | { | ||
| 19 : | $task = $request->get('task'); | ||
| 20 : | $act = $request->get('act'); | ||
| 21 : | |||
| 22 : | foreach ($request->get() as $key => $value) $renderer->addvar($key, $value); | ||
| 23 : | switch ($act) | ||
| 24 : | { | ||
| 25 : | case 'language': | ||
| 26 : | if ($task == 'new')$this->newlanguage($renderer, $request); | ||
| 27 : | else $this->editlanguage($renderer, $request); | ||
| 28 : | break; | ||
| 29 : | |||
| 30 : | case 'catalogs': | ||
| 31 : | default: | ||
| 32 : | $this->editcatalog($renderer, $request); | ||
| 33 : | break; | ||
| 34 : | } | ||
| 35 : | $renderer->display('form.tpl.php'); | ||
| 36 : | } | ||
| 37 : | |||
| 38 : | |||
| 39 : | function newlanguage(&$renderer, &$request) { | ||
| 40 : | $locales = getlocales(); | ||
| 41 : | $header = T_('Language').' : <small>'.T_('New language').'</small>'; | ||
| 42 : | $renderer->addvar('header', $header); | ||
| 43 : | $renderer->addvar('locales', $locales['locales']); | ||
| 44 : | $renderer->addvar('territories', $locales['territories'] ); | ||
| 45 : | $renderer->addvar('codesets', $locales['codesets']); | ||
| 46 : | $renderer->addvar('dateformats', $locales['dateformats']); | ||
| 47 : | $renderer->addvar('directions', $locales['directions']); | ||
| 48 : | $renderer->addvar('plural_forms', $locales['plural_forms']); | ||
| 49 : | $renderer->addvar('content', $renderer->fetch('langform.tpl.php')); | ||
| 50 : | } | ||
| 51 : | |||
| 52 : | function editlanguage(&$renderer, &$request) { | ||
| 53 : | |||
| 54 : | andphe | 1680 | $lang = mosGetParam($_REQUEST,'lang'); |
| 55 : | elpie | 971 | $language =& new mamboLanguage($lang); |
| 56 : | $header = T_('Language').' : <small>'.T_('Edit language') . " [ {$language->title} ] ".'</small>'; | ||
| 57 : | $renderer->addvar('header', $header); | ||
| 58 : | $renderer->addvar('language', $language); | ||
| 59 : | $renderer->addvar('plurals', $this->plurals()); | ||
| 60 : | $renderer->addvar('content', $renderer->fetch('langform.tpl.php')); | ||
| 61 : | } | ||
| 62 : | |||
| 63 : | function editcatalog(&$renderer, &$request) { | ||
| 64 : | $lang = $request->get('lang'); | ||
| 65 : | $language = new mamboLanguage($lang); | ||
| 66 : | $domain = $request->get('domain'); | ||
| 67 : | $catalog = new PHPGettext_catalog($domain, mamboCore::get('rootPath')."/language"); | ||
| 68 : | $catalog->setproperty('mode', _MODE_PO_); | ||
| 69 : | $catalog->setproperty('lang', $lang); | ||
| 70 : | $catalog->load(); | ||
| 71 : | $nplurals = 2; | ||
| 72 : | $_VERSION = new version(); | ||
| 73 : | |||
| 74 : | |||
| 75 : | if (strpos($catalog->headers['Last-Translator'], 'FULL NAME')) { | ||
| 76 : | $catalog->headers['Last-Translator'] = "Translation <translation@mambo-foundation.org>"; | ||
| 77 : | } | ||
| 78 : | if (strpos($catalog->headers['Language-Team'], 'LANGUAGE')) { | ||
| 79 : | $catalog->headers['Language-Team'] = "Translation <translation@mambo-foundation.org>"; | ||
| 80 : | } | ||
| 81 : | $catalog->headers['Project-Id-Version'] = $_VERSION->PRODUCT.' '.$_VERSION->RELEASE; | ||
| 82 : | $catalog->headers['Report-Msgid-Bugs-To'] = 'translation@mambo-foundation.org'; | ||
| 83 : | $catalog->headers['Plural-Forms'] = $language->plural_form['expression']; | ||
| 84 : | $catalog->headers['Content-Type'] = 'text/plain; charset='.$language->charset; | ||
| 85 : | $renderer->addvar('header', sprintf(T_('Translate Catalog: %s [%s]'),$domain, $lang)); | ||
| 86 : | $renderer->addvar('nplurals', $language->plural_form['nplurals']); | ||
| 87 : | $renderer->addbyref('catalog', $catalog); | ||
| 88 : | $renderer->addvar('domain', $domain); | ||
| 89 : | $renderer->addvar('content', $renderer->fetch('editcatalog.tpl.php')); | ||
| 90 : | } | ||
| 91 : | |||
| 92 : | |||
| 93 : | |||
| 94 : | |||
| 95 : | function plurals() { | ||
| 96 : | return array( | ||
| 97 : | array('Two forms, singular used for one only', 'nplurals=2; plural=n != 1;', array('danish','dutch','english','german','norwegian','swedish','estonian','finnish','greek','hebrew','italian','portuguese','spanish')), | ||
| 98 : | array('One single form', 'nplurals=1; plural=0;', array('Hungarian','Japanese','Korean','Turkish')), | ||
| 99 : | array('Two forms, singular used for zero and one', 'nplurals=2; plural=n>1;', array('french','brazilian portuguese')), | ||
| 100 : | array('Three forms, special case for zero', 'nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;', array('Latvian')), | ||
| 101 : | array('Three forms, special cases for one and two', 'nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;', array('Gaeilge')), | ||
| 102 : | array('Three forms, special case for numbers ending in 1[2-9]', 'nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;', array('lithuanian')), | ||
| 103 : | array('Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]', 'nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;', explode(',', 'croatian,czech,russian,slovak,ukrainian')), | ||
| 104 : | array('Three forms, special case for one and some numbers ending in 2, 3, or 4', 'nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;', array('polish')), | ||
| 105 : | array('Four forms, special case for one and all numbers ending in 02, 03, or 04', 'nplurals=4; plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;', array('slovenian')) | ||
| 106 : | ); | ||
| 107 : | } | ||
| 108 : | } | ||
| 109 : | |||
| 110 : | |||
| 111 : | if (!function_exists('array_combine')) { | ||
| 112 : | function array_combine($a, $b) { | ||
| 113 : | $c = array(); | ||
| 114 : | if (is_array($a) && is_array($b)) | ||
| 115 : | while (list(, $va) = each($a)) | ||
| 116 : | if (list(, $vb) = each($b)) | ||
| 117 : | $c[$va] = $vb; | ||
| 118 : | else | ||
| 119 : | break 1; | ||
| 120 : | return $c; | ||
| 121 : | } | ||
| 122 : | } | ||
| 123 : | csouza | 298 | ?> |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |
Web Hosting provided by Network Redux.

