Let the platform do the work

Language

Overview

The Language extension adds or overrides language strings.

This extension is applicable to both the application and module framework. For more information, please refer to the Language Framework page.

Properties

The following extension properties are available. For more information, please refer to the Extension Property documentation.

Property Value
Extension Scope All - Application & Module
Sugar Variables
  • If adding language files to application:
    $app_strings / $app_list_strings 
  • If adding language files to <module>:
    $mod_strings
Extension Directory
  • Application:
    ./custom/Extension/application/Ext/Language/
  • Module:
    ./custom/Extension/modules/<module>/Ext/Language/
Compiled Extension File
  • Application:
    ./custom/application/Ext/Language/<language_key>.lang.ext.php
  • Module: 
    ./custom/modules/<module>/Ext/Language/<language_key>.lang.ext.php
Manifest Installdef $installdefs['language']

 

Implementation

The following sections illustrate the various ways to implement a customization to a Sugar instance.

File System

Creating New Application Label

When working directly with the filesystem, you can create a file in ./custom/Extension/application/Ext/Language/ to add Labels for languages to the system. The following example will add a new Label 'LBL_EXAMPLE_LABEL' to the system: 

./custom/Extension/application/Ext/Language/<language>.<file>.php

  <?php

$app_strings['LBL_EXAMPLE_LABEL'] = 'Example Application Label';

Navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and compile your customization into./custom/application/Ext/Language/<language>.lang.ext.php

Creating New Module Label

When working directly with the filesystem, you can create a file in ./custom/Extension/modules/<module>/Ext/Language/ to add Labels for languages to a particular module. The following example will add a new Label 'LBL_EXAMPLE_MODULE_LABEL' to a module:

./custom/Extension/modules/<module>/Ext/Language/<language>.<file>.php

  <?php

$mod_strings['LBL_EXAMPLE_MODULE_LABEL'] = 'Example Module Label';

Navigate to Admin > Repair > Quick Repair and Rebuild. The system will then rebuild the extensions and compile your customization into ./custom/modules/<module>/Ext/Language/<language>.lang.ext.php

Module Loadable Package

When building a module loadable package, you can use the $installdefs['language'] index to install the extension file. 

Installdef Properties

Name Type Description
from String The basepath of the file to be installed. 
to_module String The key of the module the file is to be installed to.
language String The key of the language the file is to be installed to.

The example below will demonstrate the proper install definition that should be used in the ./manifest.php file, in order to add the Language Extension file to the system. You should note that when using this approach Sugar will automatically execute Rebuild Extensions to reflect the new Labels in the system.

./manifest.php

  <?php

$manifest = array(
    ...
);

$installdefs = array(
    'id' => 'language_Example',
    'language' => array(
        array(
            'from' => '<basepath>/Files/custom/Extension/application/Ext/Language/<language>.lang.ext.php',
            'to_module' => 'application',
            'language' => '<language>'
        )
    )
);

Alternatively, you may use the $installdefs['copy'] index to copy the file. When using this approach, you may need to manually run repair actions such as a Quick Repair and Rebuild. For more information on the $installdefs['copy'] index and module-loadable packages, please refer to the Introduction to the Manifest page.