[BUGFIX] Overwriting form language keys via _LOCAL_LANG 05/42805/6
authorRalf Zimmermann <ralf.zimmermann@tritum.de>
Sun, 23 Aug 2015 15:26:21 +0000 (17:26 +0200)
committerMarkus Klein <markus.klein@typo3.org>
Fri, 28 Aug 2015 12:19:59 +0000 (14:19 +0200)
With this patch it is possible to overwrite language keys from a XLIFF
file by TypoScript with the regular _LOCAL_LANG property.

Example:
plugin.tx_form._LOCAL_LANG.en.tx_form_view_mail\.success = Yay, that worked!

Resolves: #39280
Releases: master
Change-Id: Ic1ce1d3c065751f66d713878324e4bcb52e25330
Reviewed-on: http://review.typo3.org/42805
Reviewed-by: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
typo3/sysext/form/Classes/Localization.php
typo3/sysext/form/Resources/Private/Language/locallang.xlf [new file with mode: 0644]
typo3/sysext/form/Resources/Private/Language/locallang_controller.xlf [deleted file]

index 3788210..c69daad 100644 (file)
@@ -20,33 +20,14 @@ namespace TYPO3\CMS\Form;
 class Localization {
 
        /**
-        * File reference to the local language file
-        *
-        * @var string
-        */
-       protected $localLanguageFile;
-
-       /**
-        * Constructor
-        *
-        * @param string $localLanguageFile File reference to the local language file
-        */
-       public function __construct($localLanguageFile = 'LLL:EXT:form/Resources/Private/Language/locallang_controller.xlf') {
-               $this->localLanguageFile = (string)$localLanguageFile;
-       }
-
-       /**
         * Get a label from local language
         *
         * @param string $labelKey Key to look for
         * @return string
         */
        public function getLocalLanguageLabel($labelKey) {
-               if (TYPO3_MODE === 'FE') {
-                       $output = $GLOBALS['TSFE']->sL($this->localLanguageFile . ':' . $labelKey);
-               } else {
-                       $output = $GLOBALS['LANG']->sL($this->localLanguageFile . ':' . $labelKey);
-               }
+               $output = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($labelKey, 'form');
+
                return $output;
        }
 
diff --git a/typo3/sysext/form/Resources/Private/Language/locallang.xlf b/typo3/sysext/form/Resources/Private/Language/locallang.xlf
new file mode 100644 (file)
index 0000000..cb38da6
--- /dev/null
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
+       <file t3:id="1415814824" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:32Z" product-name="form">
+               <header/>
+               <body>
+                       <trans-unit id="tx_form_domain_model_element_button.value">
+                               <source>Push this button</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_domain_model_element_submit.value">
+                               <source>Submit form</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_domain_model_element_reset.value">
+                               <source>Clear form</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphabetic.message">
+                               <source>Use alphabetic characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphabetic.message2">
+                               <source>whitespace allowed</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphabetic.error">
+                               <source>The value contains not only alphabetic characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphanumeric.message">
+                               <source>Use alphanumeric characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphanumeric.message2">
+                               <source>whitespace allowed</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_alphanumeric.error">
+                               <source>The value contains not only alphanumeric characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_between.message">
+                               <source>The value must be between %minimum and %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_between.message2">
+                               <source>inclusively</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_between.error">
+                               <source>The value is not between %minimum and %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_between.error2">
+                               <source>inclusively</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.message">
+                               <source>(%format)</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.A">
+                               <source>dddd</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.a">
+                               <source>ddd</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.d">
+                               <source>dd</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.e">
+                               <source>d</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.B">
+                               <source>mmmm</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.b">
+                               <source>mmm</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.m">
+                               <source>mm</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.Y">
+                               <source>yyyy</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.y">
+                               <source>yy</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.H">
+                               <source>HH</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.I">
+                               <source>hh</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.M">
+                               <source>mm</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.strftime.S">
+                               <source>ss</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_date.error">
+                               <source>The value does not appear to be a valid date</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_digit.message">
+                               <source>Use digit characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_digit.error">
+                               <source>The value contains not only digit characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_email.message">
+                               <source>(john.doe@domain.com)</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_email.error">
+                               <source>This is not a valid email address</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_equals.message">
+                               <source>This field must be equal to '%field'</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_equals.error">
+                               <source>The value does not equal the value in field '%field'</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_fileallowedtypes.message">
+                               <source>(%allowedTypes)</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_fileallowedtypes.error">
+                               <source>The file type is not allowed</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_filemaximumsize.message">
+                               <source>The filesize must be smaller than %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_filemaximumsize.error">
+                               <source>The filesize is too big</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_fileminimumsize.message">
+                               <source>The filesize must be bigger than %minimum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_fileminimumsize.error">
+                               <source>The filesize is too small</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_float.message">
+                               <source>Enter a float</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_float.error">
+                               <source>The value does not appear to be a float</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_greaterthan.message">
+                               <source>The value must be greater than %minimum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_greaterthan.error">
+                               <source>The value does not appear to be greater than %minimum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_inarray.message">
+                               <source>Only a few values are possible</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_inarray.error">
+                               <source>The value does not appear to be valid</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_integer.message">
+                               <source>Use an integer</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_integer.error">
+                               <source>The value does not appear to be an integer</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_ip.message">
+                               <source>(123.123.123.123)</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_ip.error">
+                               <source>The value does not appear to be a valid IP address</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_length.message">
+                               <source>The length of the value must have a minimum of %minimum characters</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_length.message2">
+                               <source>and a maximum of %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_length.error">
+                               <source>The value is less than %minimum characters long</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_length.error2">
+                               <source>or longer than %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_lessthan.message">
+                               <source>The value must be less than %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_lessthan.error">
+                               <source>The value does not appear to be less than %maximum</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_regexp.message">
+                               <source>Use the right pattern</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_regexp.error">
+                               <source>The value does not match against pattern</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_required.message">
+                               <source>Required</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_required.error">
+                               <source>This field is required</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_uri.message">
+                               <source>The value must be a URI</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_system_validate_uri.error">
+                               <source>The value does not appear to be a URI</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_view_confirmation.message">
+                               <source>Please check your input and confirm by using the appropriate button</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_view_confirmation.confirm">
+                               <source>Confirm</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_view_confirmation.donotconfirm">
+                               <source>Go back to the form</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_view_mail.success">
+                               <source>The form has been sent successfully by mail</source>
+                       </trans-unit>
+                       <trans-unit id="tx_form_view_mail.error">
+                               <source>There was an error when sending the form by mail</source>
+                       </trans-unit>
+               </body>
+       </file>
+</xliff>
diff --git a/typo3/sysext/form/Resources/Private/Language/locallang_controller.xlf b/typo3/sysext/form/Resources/Private/Language/locallang_controller.xlf
deleted file mode 100644 (file)
index cb38da6..0000000
+++ /dev/null
@@ -1,209 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<xliff version="1.0" xmlns:t3="http://typo3.org/schemas/xliff">
-       <file t3:id="1415814824" source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:32Z" product-name="form">
-               <header/>
-               <body>
-                       <trans-unit id="tx_form_domain_model_element_button.value">
-                               <source>Push this button</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_domain_model_element_submit.value">
-                               <source>Submit form</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_domain_model_element_reset.value">
-                               <source>Clear form</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphabetic.message">
-                               <source>Use alphabetic characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphabetic.message2">
-                               <source>whitespace allowed</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphabetic.error">
-                               <source>The value contains not only alphabetic characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphanumeric.message">
-                               <source>Use alphanumeric characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphanumeric.message2">
-                               <source>whitespace allowed</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_alphanumeric.error">
-                               <source>The value contains not only alphanumeric characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_between.message">
-                               <source>The value must be between %minimum and %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_between.message2">
-                               <source>inclusively</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_between.error">
-                               <source>The value is not between %minimum and %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_between.error2">
-                               <source>inclusively</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.message">
-                               <source>(%format)</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.A">
-                               <source>dddd</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.a">
-                               <source>ddd</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.d">
-                               <source>dd</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.e">
-                               <source>d</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.B">
-                               <source>mmmm</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.b">
-                               <source>mmm</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.m">
-                               <source>mm</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.Y">
-                               <source>yyyy</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.y">
-                               <source>yy</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.H">
-                               <source>HH</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.I">
-                               <source>hh</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.M">
-                               <source>mm</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.strftime.S">
-                               <source>ss</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_date.error">
-                               <source>The value does not appear to be a valid date</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_digit.message">
-                               <source>Use digit characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_digit.error">
-                               <source>The value contains not only digit characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_email.message">
-                               <source>(john.doe@domain.com)</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_email.error">
-                               <source>This is not a valid email address</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_equals.message">
-                               <source>This field must be equal to '%field'</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_equals.error">
-                               <source>The value does not equal the value in field '%field'</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_fileallowedtypes.message">
-                               <source>(%allowedTypes)</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_fileallowedtypes.error">
-                               <source>The file type is not allowed</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_filemaximumsize.message">
-                               <source>The filesize must be smaller than %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_filemaximumsize.error">
-                               <source>The filesize is too big</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_fileminimumsize.message">
-                               <source>The filesize must be bigger than %minimum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_fileminimumsize.error">
-                               <source>The filesize is too small</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_float.message">
-                               <source>Enter a float</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_float.error">
-                               <source>The value does not appear to be a float</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_greaterthan.message">
-                               <source>The value must be greater than %minimum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_greaterthan.error">
-                               <source>The value does not appear to be greater than %minimum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_inarray.message">
-                               <source>Only a few values are possible</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_inarray.error">
-                               <source>The value does not appear to be valid</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_integer.message">
-                               <source>Use an integer</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_integer.error">
-                               <source>The value does not appear to be an integer</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_ip.message">
-                               <source>(123.123.123.123)</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_ip.error">
-                               <source>The value does not appear to be a valid IP address</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_length.message">
-                               <source>The length of the value must have a minimum of %minimum characters</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_length.message2">
-                               <source>and a maximum of %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_length.error">
-                               <source>The value is less than %minimum characters long</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_length.error2">
-                               <source>or longer than %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_lessthan.message">
-                               <source>The value must be less than %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_lessthan.error">
-                               <source>The value does not appear to be less than %maximum</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_regexp.message">
-                               <source>Use the right pattern</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_regexp.error">
-                               <source>The value does not match against pattern</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_required.message">
-                               <source>Required</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_required.error">
-                               <source>This field is required</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_uri.message">
-                               <source>The value must be a URI</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_system_validate_uri.error">
-                               <source>The value does not appear to be a URI</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_view_confirmation.message">
-                               <source>Please check your input and confirm by using the appropriate button</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_view_confirmation.confirm">
-                               <source>Confirm</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_view_confirmation.donotconfirm">
-                               <source>Go back to the form</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_view_mail.success">
-                               <source>The form has been sent successfully by mail</source>
-                       </trans-unit>
-                       <trans-unit id="tx_form_view_mail.error">
-                               <source>There was an error when sending the form by mail</source>
-                       </trans-unit>
-               </body>
-       </file>
-</xliff>