Review main Merged

17615[BUGFIX] Numeric translation keys aren't translated right in XML files

Reinhard Führicht CR +2 V +2 Normal +54 −17 updated 06/03/13, 20:49

Commit message

When working with the "old" XML based translation files,
numeric keys aren't translated properly.
The reason is, that LocallangXmlParser uses array_merge to combine the
translation arrays of the default language and the current language.
array_merge renumbers numeric keys. Therefore, numeric key in
translation files result in wrong translations in Frontend.

Review

  • Code review CR +2
    • Andreas Wolf +2
  • Verified V +2
    • Andreas Wolf +2

Files 3

Review log 22

  1. Dmitry Dulepov commented on patch set 1 02/09/13, 22:11

    Fails; I would prefer that you didn't submit this I believe this will not work properly. array_merge overrides elements with the same key but the "+" operator does not override elements with the same key from the first array. The goal of this code is to override source with target. Simple test: ============= $ php -r '$source = array("1" => "from source"); $target = array("1" => "from target"); print_r($source + $target);' Array ( [1] => from source ) $ ============= If I am wrong, please, tell me and I will remove my -1.
  2. Reinhard Führicht commented on patch set 1 02/09/13, 22:11

    I created a simple translation file: <label index="1">Translation for 1</label> <label index="2">Translation for 2</label> <label index="20">Translation for 20</label> And a simple TS: page { 1 = TEXT 1.data = LLL:path/to/file/lang.xml:1 2 = TEXT 2.data = LLL:path/to/file/lang.xml:2 3 = TEXT 3.data = LLL:path/to/file/lang.xml:20 } I am not familiar with how to add unit tests to TYPO3. I had a look at the sources from GIT, but there is no "tests" directory or similar. I could try to add unit tests for that, but I would need a hint or two on how to do that.
  3. Reinhard Führicht commented on patch set 1 02/09/13, 22:11

    Thanks for the hint! I will give it a try.
  4. Reinhard Führicht commented on patch set 1 02/09/13, 22:11

    Of course, you are right. Thanks for pointing that out, I missed it in the docs. Then it should be enough to switch the two arrays $parsedData and $parsedDataTarget, right? I will try to add a unit test too and create a new patch.
  5. Andreas Wolf commented on patch set 2 02/09/13, 22:11

    (1 inline comment)

    locallangNumericKeys.xml:17

    I'd like to have some key like 10 here, as this means a gap in the numbering and would definitely lead to a failure if the keys are renumbered. The fixture is also clearer then, because the renumbering (1..3->0..2) is not as obvious here as it would be with 1..10->0..3.
  6. Reinhard Führicht uploaded patch set 2 02/09/13, 22:11

  7. Andreas Wolf commented on patch set 4 02/09/13, 22:11

    Verified; Looks good to me, but someone else must approve
  8. Andreas Wolf uploaded patch set 5 02/09/13, 22:11

  9. Andreas Wolf commented on patch set 5 V 0 02/09/13, 22:11

    by team member; Looks good to me, approved Refined Dmitry's changes to have a data provider and test each of the different values independently.
  10. Dmitry Dulepov uploaded patch set 4 02/09/13, 22:11

  11. Dmitry Dulepov commented on patch set 4 02/09/13, 22:11

    Verified; Looks good to me, but someone else must approve I changed unit test to test for actual label overloading.
  12. Reinhard Führicht uploaded patch set 3 02/09/13, 22:11

  13. Reinhard Führicht commented on patch set 4 02/09/13, 22:11

    Hi Dmitry, I thought about doing that too. Correct me if I am wrong, but if this patch breaks something, "canOverrideLlxml" should fail as it already test the "overloading" feature. Is it necessary to test it again with numeric keys? Or should we create a separate test "canOverloadNumericKeys"? Don't get me wrong, I don't want to nag. I just want to do it the right way.
  14. Philipp Gampe commented on patch set 1 02/09/13, 22:11

    Looks good to me, but someone else must approve Do you have a test extension, or even better could you create unit tests for this?
  15. Mattias Nilsson commented on patch set 1 02/09/13, 22:11

    Looks good to me, but someone else must approve
  16. Mr. Jenkins commented on patch set 1 02/09/13, 22:11

  17. Mr. Jenkins commented on patch set 2 02/09/13, 22:11

  18. Mr. Jenkins commented on patch set 3 02/09/13, 22:11

  19. Mr. Jenkins commented on patch set 4 02/09/13, 22:11

  20. Mr. Jenkins commented on patch set 5 02/09/13, 22:11

  21. Wouter Wolters commented on patch set 1 02/09/13, 22:11

  22. Andreas Wolf merged patch set 6 02/09/13, 22:11