Project

General

Profile

Support #7340

Add possibility to use |get_lang Twig filter with multiple params

Added by Yannick Warnier almost 5 years ago. Updated almost 5 years ago.

Status:
Feature implemented
Priority:
Normal
Assignee:
Category:
Styles, Layout & Accessibility
Target version:
Start date:
20/10/2014
Due date:
% Done:

100%

Estimated time:
Complexity:
Normal
SCRUM pts - complexity:
?

Description

For those composed string of type $HelloXWelcomeToCourse = "Hello %s, welcome to the course", we cannot call the translated string from a Twig template (something like {{ HelloXWelcomeToCourse | get_lang(user.name) }} ).

The declaration of this filter is in main/inc/lib/template.lib.php +110

Explain how to do it or hack the get_lang filter to allow it.

References

History

#1

Updated by Julio Montoya almost 5 years ago

  • Status changed from Assigned to Needs more info
  • Assignee changed from Julio Montoya to Yannick Warnier

There's already an example here:

https://github.com/chamilo/chamilo-lms/blob/1.9.x/plugin/show_user_info/template.tpl#L28

See:

http://twig.sensiolabs.org/doc/filters/format.html

PHP

$strings['WelcomeToChamiloUserX']     = "Welcome to Chamilo %s!";

Template:

{{ "WelcomeToChamiloUserX" | get_lang | format(show_user_info.user_info.complete_name) }}           

#2

Updated by Yannick Warnier almost 5 years ago

  • Tracker changed from Feature to Support
  • Status changed from Needs more info to Feature implemented
  • Assignee changed from Yannick Warnier to Julio Montoya
  • % Done changed from 0 to 100

Thanks, added info to the wiki (in coding conventions)

Also available in: Atom PDF