Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-13580

Set translation domain implicitly in extensions

    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 ==

        Attachments

          Activity

            People

            • Assignee:
              mlutfy Mathieu Lutfy
              Reporter:
              timotten Tim Otten
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 40 minutes
                3h 40m