Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated sprintf rules in core translations #6582

Closed
chillu opened this issue Jan 30, 2017 · 13 comments
Closed

Replace deprecated sprintf rules in core translations #6582

chillu opened this issue Jan 30, 2017 · 13 comments

Comments

@chillu
Copy link
Member

chillu commented Jan 30, 2017

We've deprecated the use of sprintf() style placeholders (e.g. %s) in _t() calls with #6558 - but core still uses it. There's around two dozen strings in core. Ideally we also replace this in the existing translations as well, so the translation strings don't get invalidated (we either have to fix them or remove them, otherwise will see stray %s in the UI)

@robbieaverill
Copy link
Contributor

robbieaverill commented Feb 4, 2017

@chillu there's a few cases in the tests, especially i18nTest that still use either sprintf(_t(...)) or unnamed placeholders. Some of the tests in that class are also specifically testing the legacy behaviour. Do you want these cases updated/removed?

@chillu
Copy link
Member Author

chillu commented Feb 8, 2017

Correct, everything referring to %s in i18nTest.php should be rewritten to test the new, associative array format. Since the functionality is deprecated, I'd say we should remove the tests at the same time as the feature itself, unless it's hard to separate out the existing tests

@robbieaverill
Copy link
Contributor

@chillu I've removed sprintf and %s use in the i18n related tests. There was one change in i18nTestModuleInclude.ss re: SPRINTFINCLUDENONAMESPACE which didn't seem to "magically" inherit the template name as a prefix which is defined in the test class. @tractorcow had a look at this with me and we weren't sure why/how it works currently, but I figure that it's an ambiguous mistake that works for some reason so I've added the template prefix to it to be more explicit.

I've also removed the "legacy" assertions which were explicitly testing a bunch of %s placeholders and were marked as deprecated.

@tractorcow
Copy link
Contributor

The issue was with legacy <% _t() %> template behaviour.

    function OldTPart_QuotedString(&$res, $sub)
    {
        $entity = $sub['String']['text'];
        if (strpos($entity, '.') === false) {
            $res['php'] .= "\$scope->XML_val('I18NNamespace').'.$entity'";
        } else {
            $res['php'] .= "'$entity'";
        }
    }

I suggest removing this, as it's been deprecated for quite some time. Templates should use <%t from now on.

@robbieaverill
Copy link
Contributor

@tractorcow do you want me to whip this out as part of the PR?

@tractorcow
Copy link
Contributor

It's up to you; It can be another PR or just a part of this if you like.

@robbieaverill
Copy link
Contributor

@tractorcow @chillu are we ready for this PR now re: Transifex? If so I'll rebase #6598 tomorrow.

@tractorcow
Copy link
Contributor

yes please

@robbieaverill
Copy link
Contributor

FYI @tractorcow I haven't removed the legacy template parser functions in #6598 - they're marked as deprecated against 5.0, didn't want to remove them in this PR.

@tractorcow
Copy link
Contributor

Thanks @robbieaverill that's good. :D I'll review your work next week.

@dhensby
Copy link
Contributor

dhensby commented Jul 27, 2017

bump @tractorcow

@tractorcow
Copy link
Contributor

cms and versioned need rebasing, @robbieaverill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants