Details
-
Type:
Improvement
-
Status: Done/Fixed
-
Priority:
Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.4.0
-
Fix Version/s: Unscheduled
-
Component/s: Extension System
-
Labels:None
-
Documentation Required?:Developer Doc
-
Funding Source:Needs Funding
Description
The translation team decided to store strings for extensions in different projects/domains than core, so extensions should not rely on the default "translation domain". When writing extension code that uses
{ts} or ts(), one must currently specify the "translation domain" as an extra argument. However, explicitly passing the domain with each invocation of {ts}or ts() would be cumbersome and error-prone. We need a way to pass the domain in a more automatic fashion.
Below are some code-snippets discussed during the Dalesbridge sprint.
== Smarty example ==
{crmScope extensionKey="com.example.myext"}{ts}
This is my string!
{/ts} {/crmScope}== Javascript example ==
CRM.translate('com.example.myext', function(ts)
{ alert(ts('This is my string!')); });== Javascript example (DEPRECATED) ==
CRM.extension('com.example.myext', [], function($, ts){ alert(ts('This is my string!')); }
);
== PHP example ==
- https://gist.github.com/totten/a2bac7904a4cfd9bb9bd (with namespaces – supported with civix codegen)
- https://gist.github.com/totten/2f3d4d6e6da5c2d3857b (with named instances – supported with new core class)