Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Internacionalizacao.

  • Loading branch information...
commit 0a3456e730a1acced2301e3dd11a1c4e02f1e126 1 parent 7d7a2c5
@jrbasso authored
View
1  .gitignore
@@ -0,0 +1 @@
+locale/*/LC_MESSAGES/*.mo
View
85 locale/meio_upload.pot
@@ -0,0 +1,85 @@
+# LANGUAGE translation of CakePHP Application
+# Copyright YEAR NAME <EMAIL@ADDRESS>
+# No version information was available in the source files.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PROJECT VERSION\n"
+"POT-Creation-Date: 2009-05-21 22:34-0300\n"
+"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
+"Last-Translator: NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
+
+#: \models\behaviors\meio_upload.php:149
+msgid "This field has not been defined between the parameters of MeioUploadBehavior."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:152
+msgid "The directory where the file would be placed there or is protected against writing."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:155
+msgid "The file can not be empty."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:158
+msgid "There were problems in uploading the file."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:161
+msgid "The maximum file size is exceeded."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:164
+msgid "Invalid file type."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:167
+msgid "Invalid file extension."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:191
+msgid "MeioUploadBehavior Error: The field \"%s\" doesn't exists in the model \"%s\"."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:199
+msgid "MeioUploadBehavior Error: The default option must be the filename with extension."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:206
+msgid "MeioUploadBehavior Error: The thumbsizes names must be alphanumeric."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:283
+msgid "MeioUploadBehavior Error: The max_size option format is invalid."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:299
+msgid "MeioUploadBehavior Error: The max_size unit is invalid."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:341
+msgid "MeioUploadBehavior Error: The field \"%s\" wasn't declared as part of the MeioUploadBehavior in model \"%s\"."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:365
+msgid "MeioUploadBehavior Error: The directory %s does not exist and cannot be created."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:369
+msgid "MeioUploadBehavior Error: The directory %s does not exist."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:376
+msgid "MeioUploadBehavior Error: The directory %s isn't writable."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:627
+msgid "Problems in the copy of the file."
+msgstr ""
+
View
87 locale/pt_br/LC_MESSAGES/meio_upload.po
@@ -0,0 +1,87 @@
+# LANGUAGE translation of CakePHP Application
+# Copyright YEAR NAME <EMAIL@ADDRESS>
+# No version information was available in the source files.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: MeioUpload\n"
+"POT-Creation-Date: 2009-05-21 22:34-0300\n"
+"PO-Revision-Date: 2009-05-21 22:37-0300\n"
+"Last-Translator: Juan Basso <jrbasso@gmail.com>\n"
+"Language-Team: Juan Basso <jrbasso@gmail.com>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n>1;\n"
+"X-Poedit-Language: Portuguese\n"
+"X-Poedit-Country: BRAZIL\n"
+"X-Poedit-SourceCharset: utf-8\n"
+
+#: \models\behaviors\meio_upload.php:149
+msgid "This field has not been defined between the parameters of MeioUploadBehavior."
+msgstr "Este campo não foi definido entre os parâmetros do MeioUploadBehavior."
+
+#: \models\behaviors\meio_upload.php:152
+msgid "The directory where the file would be placed there or is protected against writing."
+msgstr "O diretório onde este arquivo seria colocado não existe ou é protegido contra escrita."
+
+#: \models\behaviors\meio_upload.php:155
+msgid "The file can not be empty."
+msgstr "O arquivo não pode ser vazio."
+
+#: \models\behaviors\meio_upload.php:158
+msgid "There were problems in uploading the file."
+msgstr "Ocorreram problemas no upload do arquivo."
+
+#: \models\behaviors\meio_upload.php:161
+msgid "The maximum file size is exceeded."
+msgstr "O tamanho máximo de arquivo foi excedido."
+
+#: \models\behaviors\meio_upload.php:164
+msgid "Invalid file type."
+msgstr "Tipo de arquivo inválido."
+
+#: \models\behaviors\meio_upload.php:167
+msgid "Invalid file extension."
+msgstr "Extensão de arquivo inválida."
+
+#: \models\behaviors\meio_upload.php:191
+msgid "MeioUploadBehavior Error: The field \"%s\" doesn't exists in the model \"%s\"."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:199
+msgid "MeioUploadBehavior Error: The default option must be the filename with extension."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:206
+msgid "MeioUploadBehavior Error: The thumbsizes names must be alphanumeric."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:283
+msgid "MeioUploadBehavior Error: The max_size option format is invalid."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:299
+msgid "MeioUploadBehavior Error: The max_size unit is invalid."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:341
+msgid "MeioUploadBehavior Error: The field \"%s\" wasn't declared as part of the MeioUploadBehavior in model \"%s\"."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:365
+msgid "MeioUploadBehavior Error: The directory %s does not exist and cannot be created."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:369
+msgid "MeioUploadBehavior Error: The directory %s does not exist."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:376
+msgid "MeioUploadBehavior Error: The directory %s isn't writable."
+msgstr ""
+
+#: \models\behaviors\meio_upload.php:627
+msgid "Problems in the copy of the file."
+msgstr "Problema na cópia do arquivo."
+
View
141 models/behaviors/meio_upload.php
@@ -64,7 +64,7 @@ class MeioUploadBehavior extends ModelBehavior {
/**
* The default options for the behavior
*/
- var $default_options = array(
+ var $defaultOptions = array(
'dir' => '',
'allowed_mime' => array(),
'allowed_ext' => array(),
@@ -77,91 +77,42 @@ class MeioUploadBehavior extends ModelBehavior {
'filesize' => 'filesize',
'mimetype' => 'mimetype'
),
- 'validations' => array(
- 'FieldName' => array(
- 'rule' => array('uploadCheckFieldName'),
- 'check' => true,
- 'message' => 'Este campo não foi definido entre os parâmetros do MeioUploadBehavior.'
- ),
- 'Dir' => array(
- 'rule' => array('uploadCheckDir'),
- 'check' => true,
- 'message' => 'O diretório onde este arquivo seria colocado não existe ou é protegido contra escrita.'
- ),
- 'Empty' => array(
- 'rule' => array('uploadCheckEmpty'),
- 'check' => true,
- 'on' => 'create',
- 'message' => 'O arquivo não pode ser vazio'
- ),
- 'UploadError' => array(
- 'rule' => array('uploadCheckUploadError'),
- 'check' => true,
- 'message' => 'Ocorreram problemas no upload do arquivo.'
- ),
- 'MaxSize' => array(
- 'rule' => array('uploadCheckMaxSize'),
- 'check' => true,
- 'message' => 'O tamanho máximo de arquivo foi excedido.'
- ),
- 'InvalidMime' => array(
- 'rule' => array('uploadCheckInvalidMime'),
- 'check' => true,
- 'message' => 'Tipo de arquivo inválido.'
- ),
- 'InvalidExt' => array(
- 'rule' => array('uploadCheckInvalidExt'),
- 'check' => true,
- 'message' => 'Extensão de arquivo inválida.'
- )
- )
+ 'validations' => array()
);
- var $default_validations = array(
+ var $defaultValidations = array(
'FieldName' => array(
'rule' => array('uploadCheckFieldName'),
- 'check' => true,
- 'message' => 'Este campo não foi definido entre os parâmetros do MeioUploadBehavior.'
+ 'check' => true
),
'Dir' => array(
'rule' => array('uploadCheckDir'),
- 'check' => true,
- 'message' => 'O diretório onde este arquivo seria colocado não existe ou é protegido contra escrita.'
+ 'check' => true
),
'Empty' => array(
'rule' => array('uploadCheckEmpty'),
'check' => true,
- 'on' => 'create',
- 'message' => 'O arquivo não pode ser vazio'
+ 'on' => 'create'
),
'UploadError' => array(
'rule' => array('uploadCheckUploadError'),
- 'check' => true,
- 'message' => 'Ocorreram problemas no upload do arquivo.'
+ 'check' => true
),
'MaxSize' => array(
'rule' => array('uploadCheckMaxSize'),
- 'check' => true,
- 'message' => 'O tamanho máximo de arquivo foi excedido.'
+ 'check' => true
),
'InvalidMime' => array(
'rule' => array('uploadCheckInvalidMime'),
- 'check' => true,
- 'message' => 'Tipo de arquivo inválido.'
+ 'check' => true
),
'InvalidExt' => array(
'rule' => array('uploadCheckInvalidExt'),
- 'check' => true,
- 'message' => 'Extensão de arquivo inválida.'
+ 'check' => true
)
);
/**
- * The message for move error.
- */
- var $moveErrorMsg = 'Ocorreram problemas na cópia do arquivo.';
-
- /**
* The array that saves the $options for the behavior
*/
var $__fields = array();
@@ -188,6 +139,39 @@ class MeioUploadBehavior extends ModelBehavior {
var $__filesToRemove = array();
/**
+ * Constructor
+ *
+ * @author Juan Basso
+ */
+ function __construct() {
+ $messages = array(
+ 'FieldName' => array(
+ 'message' => __d('meio_upload', 'This field has not been defined between the parameters of MeioUploadBehavior.', true)
+ ),
+ 'Dir' => array(
+ 'message' => __d('meio_upload', 'The directory where the file would be placed there or is protected against writing.', true)
+ ),
+ 'Empty' => array(
+ 'message' => __d('meio_upload', 'The file can not be empty.', true)
+ ),
+ 'UploadError' => array(
+ 'message' => __d('meio_upload', 'There were problems in uploading the file.', true)
+ ),
+ 'MaxSize' => array(
+ 'message' => __d('meio_upload', 'The maximum file size is exceeded.', true)
+ ),
+ 'InvalidMime' => array(
+ 'message' => __d('meio_upload', 'Invalid file type.', true)
+ ),
+ 'InvalidExt' => array(
+ 'message' => __d('meio_upload', 'Invalid file extension.', true)
+ )
+ );
+ $this->defaultValidations = $this->arrayMerge($this->defaultValidations, $messages);
+ $this->defaultOptions['validations'] = $this->defaultValidations;
+ }
+
+ /**
* Setup the behavior. It stores a reference to the model, merges the default options with the options for each field, and setup the validation rules.
*
* @author Vinicius Mendes
@@ -204,22 +188,22 @@ function setup(&$model, $config=array()) {
// Check if given field exists
if (!$model->hasField($field)) {
- trigger_error('MeioUploadBehavior Error: The field "'.$field.'" doesn\'t exists in the model "'.$model->name.'".', E_USER_WARNING);
+ trigger_error(sprintf(__d('meio_upload', 'MeioUploadBehavior Error: The field "%s" doesn\'t exists in the model "%s".', true), $field, $model->name), E_USER_WARNING);
}
// Merge given options with defaults
- $options = $this->arrayMerge($this->default_options, $options);
+ $options = $this->arrayMerge($this->defaultOptions, $options);
// Including the default name to the replacements
if ($options['default']) {
if (!preg_match('/^.+\..+$/',$options['default'])) {
- trigger_error('MeioUploadBehavior Error: The default option must be the filename with extension.', E_USER_ERROR);
+ trigger_error(__d('meio_upload', 'MeioUploadBehavior Error: The default option must be the filename with extension.', true), E_USER_ERROR);
}
$this->_includeDefaultReplacement($options['default']);
}
// Verifies if the thumbsizes names is alphanumeric
foreach ($options['thumbsizes'] as $name => $size) {
if (!preg_match('/^[0-9a-zA-Z]+$/',$name)) {
- trigger_error('MeioUploadBehavior Error: The thumbsizes names must be alphanumeric.', E_USER_ERROR);
+ trigger_error(__d('meio_upload', 'MeioUploadBehavior Error: The thumbsizes names must be alphanumeric.', true), E_USER_ERROR);
}
}
// Process the max_size if it is not numeric
@@ -258,17 +242,18 @@ function setup(&$model, $config=array()) {
function arrayMerge($arr, $ins) {
if (is_array($arr)) {
if (is_array($ins)) {
- foreach ($ins as $k=>$v) {
- if (isset($arr[$k])&&is_array($v)&&is_array($arr[$k])) {
+ foreach ($ins as $k => $v) {
+ if (isset($arr[$k]) && is_array($v) && is_array($arr[$k])) {
$arr[$k] = $this->arrayMerge($arr[$k],$v);
+ } else {
+ $arr[$k] = $v;
}
- else $arr[$k] = $v;
}
}
- } elseif (!is_array($arr)&&(strlen($arr)==0||$arr==0)) {
- $arr=$ins;
+ } elseif (!is_array($arr) && (strlen($arr) == 0 || $arr == 0)) {
+ $arr = $ins;
}
- return($arr);
+ return $arr;
}
/**
@@ -295,7 +280,7 @@ function sizeToBytes($size) {
return $size;
}
if (!preg_match('/^[1-9][0-9]* (kb|mb|gb|tb)$/i', $size)) {
- trigger_error('MeioUploadBehavior Error: The max_size option format is invalid.', E_USER_ERROR);
+ trigger_error(__d('meio_upload', 'MeioUploadBehavior Error: The max_size option format is invalid.', true), E_USER_ERROR);
return 0;
}
list ($size, $unit) = explode(' ',$size);
@@ -311,7 +296,7 @@ function sizeToBytes($size) {
if (strtolower($unit) == 'tb') {
return $size * 1099511627776;
}
- trigger_error('MeioUploadBehavior Error: The max_size unit is invalid.', E_USER_ERROR);
+ trigger_error(__d('meio_upload', 'MeioUploadBehavior Error: The max_size unit is invalid.', true), E_USER_ERROR);
return 0;
}
@@ -335,8 +320,8 @@ function setupValidation($fieldName, $options) {
} else {
$this->__model->validate[$fieldName] = array();
}
- $this->__model->validate[$fieldName] = $this->arrayMerge($this->default_validations,$this->__model->validate[$fieldName]);
- $this->__model->validate[$fieldName] = $this->arrayMerge($options['validations'],$this->__model->validate[$fieldName]);
+ $this->__model->validate[$fieldName] = $this->arrayMerge($this->defaultValidations, $this->__model->validate[$fieldName]);
+ $this->__model->validate[$fieldName] = $this->arrayMerge($options['validations'], $this->__model->validate[$fieldName]);
}
/**
@@ -353,7 +338,7 @@ function uploadCheckFieldName(&$model, $data,$other) {
if (isset($this->__fields[$fieldName])) {
return true;
} else {
- $this->log('UploadBehavior Error: The field "'.$fieldName.'" wasn\'t declared as part of the UploadBehavior in model "'.$model->name.'".');
+ $this->log(sprintf(__d('meio_upload', 'MeioUploadBehavior Error: The field "%s" wasn\'t declared as part of the MeioUploadBehavior in model "%s".', true), $fieldName, $model->name));
return false;
}
}
@@ -377,18 +362,18 @@ function uploadCheckDir(&$model, $data) {
if (!is_dir($options['dir'])) {
if ($options['create_directory']) {
if (!$this->Folder->mkdir($options['dir'])) {
- trigger_error('UploadBehavior Error: The directory '.$options['dir'].' does not exist and cannot be created.', E_USER_WARNING);
+ trigger_error(sprintf(__d('meio_upload', 'MeioUploadBehavior Error: The directory %s does not exist and cannot be created.', true), $options['dir']), E_USER_WARNING);
return false;
}
} else {
- trigger_error('UploadBehavior Error: The directory'.$options['dir'].' does not exist.', E_USER_WARNING);
+ trigger_error(sprintf(__d('meio_upload', 'MeioUploadBehavior Error: The directory %s does not exist.', true), $options['dir']), E_USER_WARNING);
return false;
}
}
// Check if directory is writable
if (!is_writable($options['dir'])) {
- trigger_error('UploadBehavior Error: The directory '.$options['dir'].' isn\'t writable.', E_USER_WARNING);
+ trigger_error(sprintf(__d('meio_upload', 'MeioUploadBehavior Error: The directory %s isn\'t writable.', true), $options['dir']), E_USER_WARNING);
return false;
}
}
@@ -639,7 +624,7 @@ function beforeSave(&$model) {
// Attempt to move uploaded file
if (!move_uploaded_file($model->data[$model->name][$fieldName]['tmp_name'], $saveAs)) {
- $model->validationErrors[$field] = $moveErrorMsg;
+ $model->validationErrors[$field] = __d('meio_upload', 'Problems in the copy of the file.', true);
return false;
}
Please sign in to comment.
Something went wrong with that request. Please try again.