function _potx_save_string in Translation template extractor 7.2
Same name and namespace in other branches
- 8 potx.inc \_potx_save_string()
- 5.2 potx.inc \_potx_save_string()
- 5 potx.inc \_potx_save_string()
- 6.3 potx.inc \_potx_save_string()
- 6 potx.inc \_potx_save_string()
- 6.2 potx.inc \_potx_save_string()
- 7.3 potx.inc \_potx_save_string()
- 7 potx.inc \_potx_save_string()
Default $save_callback used by the potx system. Saves values to global arrays to reduce memory consumption problems when passing around big chunks of values.
Parameters
$value: The string value. If NULL, the array of collected values are returned for the given $string_mode.
$context: From Drupal 7, separate contexts are supported. POTX_CONTEXT_NONE is the default, if the code does not specify a context otherwise.
$file: Name of file where the string was found.
$line: Line number where the string was found.
$string_mode: String mode: POTX_STRING_INSTALLER, POTX_STRING_RUNTIME or POTX_STRING_BOTH.
1 call to _potx_save_string()
- potx_drush_extract in ./
potx.drush.inc - Drush command callback.
5 string references to '_potx_save_string'
- PotxTestCase::buildOutput in tests/
potx.test - Build the output from parsed files.
- PotxTestCase::parseFile in tests/
potx.test - Parse the given file with the given API version.
- PotxTestCase::testDrupal8ShippedConfiguration in tests/
potx.test - Test parsing of Drupal 8 shipped configuration files.
- potx_drush_extract in ./
potx.drush.inc - Drush command callback.
- potx_select_component_form_submit in ./
potx.admin.inc - Generate translation template or translation file for the requested component.
File
- ./
potx.inc, line 2587 - Extraction API used by the web and command line interface.
Code
function _potx_save_string($value = NULL, $context = NULL, $file = NULL, $line = 0, $string_mode = POTX_STRING_RUNTIME) {
global $_potx_strings, $_potx_install;
if (isset($value)) {
// Value set but empty. Mark error on empty translatable string. Only trim
// for empty string checking, since we should store leading/trailing
// whitespace as it appears in the string otherwise.
$check_empty = trim($value);
if (empty($check_empty)) {
potx_status('error', t('Empty string attempted to be localized. Please do not leave test code for localization in your source.'), $file, $line);
return;
}
switch ($string_mode) {
case POTX_STRING_BOTH:
// Mark installer strings as duplicates of runtime strings if
// the string was both recorded in the runtime and in the installer.
$_potx_install[$value][$context][$file][] = $line . ' (dup)';
// Break intentionally missing.
case POTX_STRING_RUNTIME:
// Mark runtime strings as duplicates of installer strings if
// the string was both recorded in the runtime and in the installer.
$_potx_strings[$value][$context][$file][] = $line . ($string_mode == POTX_STRING_BOTH ? ' (dup)' : '');
break;
case POTX_STRING_INSTALLER:
$_potx_install[$value][$context][$file][] = $line;
break;
}
}
else {
return $string_mode == POTX_STRING_RUNTIME ? $_potx_strings : $_potx_install;
}
}