Bug #51920

Unable to change language in CLI mode with the current localization utility

Added by DANIEL Rémy about 5 years ago. Updated over 1 year ago.

Status:
Under Review
Priority:
Should have
Assignee:
-
Category:
Extbase + l10n
Target version:
-
Start date:
2013-09-11
Due date:
% Done:

0%

TYPO3 Version:
6.2
PHP Version:
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

I have some batch processing in CLI mode (thus with a BE context).
In a multilingual website, a same batch can process a task for all the defined languages, one after an other.

But the localization utility initialize only once the LOCAL_LANG array, only for the first queried language.
This leads into some translation issues in the frontend when a content processed by a batch process is rendered.

Actually, I have added to the class TYPO3\CMS\Extbase\Utility\LocalizationUtility a method for reseting the LOCAL_LANG array, which I call when I want to change the language.

But maybe there is a proper way, or maybe we should have an api to change the current language ?


Related issues

Related to TYPO3 Core - Feature #82354: Add possibility to get a label in a specific language in LocalizationUtility::translate() Closed 2017-09-07

History

#1 Updated by DANIEL Rémy about 5 years ago

This is the method added to \TYPO3\CMS\Extbase\Utility\LocalizationUtility

    /**
     * Reset the loaded translation
     * If $extensionName is given, the reset apply only for this $extensionName keys.
     *
     * @param  [type] $extensionName [optional] name of the extension (camelCase)
     * @return void
     */
    static public function reset($extensionName = NULL) {
        if (NULL !== $extensionName) {
            if (isset(self::$LOCAL_LANG[$extensionName])) {
                unset(self::$LOCAL_LANG[$extensionName]);
            }
        } else {
            self::$LOCAL_LANG = array();
        }
    }

#2 Updated by Alexander Opitz about 4 years ago

  • Status changed from New to Needs Feedback

Hi,

was this issue fixed or does it still exists?

#3 Updated by DANIEL Rémy about 4 years ago

Hi

Not fixed, as far as I know.
The project for which I needed this was not updated to the latest version of TYPO3.

Here is the method I added to TYPO3\CMS\Extbase\Utility\LocalizationUtility:

    /**
     * Reset the loaded translation
     * If $extensionName is given, the reset apply only for this $extensionName keys.
     *
     * @param  [type] $extensionName [optional] name of the extension (camelCase)
     * @return void
     */
    static public function reset($extensionName = NULL) {
        if (NULL !== $extensionName) {
            if (isset(self::$LOCAL_LANG[$extensionName])) {
                unset(self::$LOCAL_LANG[$extensionName]);
            }
        } else {
            self::$LOCAL_LANG = array();
        }
    }

I call this method in my batch command when I start to work on a specific language.
Please tell me if you know an other way of doing this, or if you need me that I push something to gerrit.

Cheers

#4 Updated by DANIEL Rémy about 4 years ago

Posted twice the method... Too early in the morning ;)

#5 Updated by Alexander Opitz about 4 years ago

  • Project changed from Extbase MVC Framework to TYPO3 Core
  • Category changed from Extbase: - Language to Extbase
  • Status changed from Needs Feedback to New
  • Target version set to 7.0
  • TYPO3 Version set to 6.2
  • Is Regression set to No

#6 Updated by Mathias Schreiber almost 4 years ago

  • Target version changed from 7.0 to 7.1 (Cleanup)

#7 Updated by Benni Mack over 3 years ago

  • Target version changed from 7.1 (Cleanup) to 7.4 (Backend)

#8 Updated by Susanne Moog over 3 years ago

  • Target version changed from 7.4 (Backend) to 7.5

#9 Updated by Benni Mack about 3 years ago

  • Target version deleted (7.5)

#10 Updated by Gerrit Code Review over 2 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#11 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#12 Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#13 Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#14 Updated by Gerrit Code Review over 2 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#15 Updated by Gerrit Code Review over 2 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#16 Updated by Gerrit Code Review over 1 year ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#17 Updated by Gerrit Code Review over 1 year ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#18 Updated by Gerrit Code Review over 1 year ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#19 Updated by Gerrit Code Review over 1 year ago

Patch set 10 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#20 Updated by Gerrit Code Review over 1 year ago

Patch set 11 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#21 Updated by Gerrit Code Review over 1 year ago

Patch set 12 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/48112

#22 Updated by Riccardo De Contardi over 1 year ago

  • Category changed from Extbase to Extbase + l10n

#23 Updated by Tymoteusz Motylewski about 1 year ago

  • Related to Feature #82354: Add possibility to get a label in a specific language in LocalizationUtility::translate() added

Also available in: Atom PDF