UIZE JavaScript Framework

MODULES Uize.Loc.Pseudo

1. Introduction

The Uize.Loc.Pseudo module provides methods to facilitate the pseudo-localization of the resource strings of an application.

DEVELOPERS: Chris van Rensburg

1.1. In a Nutshell

1.1.1. What is Pseudo-localization?

Pseudo-localization is a process of programmatically "translating" application text (typically English) to a pseudo-locale to aid in identifying i18n (internationalization) and L10n (localization) issues in the application.

Consider the following example of text before and after pseudo-localization...

SOURCE TEXT

Your account settings have been saved.

PSEUDO-LOCALIZED TEXT

[Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.]

By looking at the pseudo-localized text, you can tell that it has been derived from the source English text, which means that pseudo-localized text is still sufficiently readable that various people involved in design, development, and testing can navigate through the user interface of an application in the pseudo-localized state.

1.1.1.1. Basic Processes

The technique of pseudo-localization involves applying the following three processes to the original source text...

accenting - this is the process of converting ASCII alphabetical characters to accented Unicode versions
expansion - this is the process of adding extra expansion characters to simulate the expansion that typically occurs when English text is translated to languages like German, French, Spanish, Portuguese, etc.
wrapping - this is the process of wrapping translated text with characters (typically square brackets) to indicate the boundaries of individual resource strings and help to identify issues with truncation and concatenation

These processes are discussed in further detail in the section Pseudo-localization Features.

1.1.1.2. Advantages of Pseudo-localization

As an i18n technique, pseudo-localization offers the following advantages...

1.1.1.2.1. It's Free

Because pseudo-localization can be performed programmatically, it is essentially a free form of pseudo-translation.

Translation using human translators can be a costly process. Pseudo-localization is a cost effective alternative to traditional translation when one is only trying to expose issues with internationalization (e.g. hard-coded text) or localization (e.g. layout issues).

1.1.1.2.2. It's Immediate

Because pseudo-localization can be performed programmatically, results can be available immediately for review.

Translation using human translators can be slow and is certainly not instantaneous. Pseudo-localization can be a virtually instantaneous process, allowing designers, developers, testers, and others to discover and address problems earlier in the development cycle, without having to be slowed down by a translation process that could take days or even weeks.

1.1.1.2.3. It Makes Testing Easier

Because pseudo-localized text is still readable as English, pseudo-localization makes it easier to test an application to discover i18n and L10n issues than if the text were truly translated to another language.

Pseudo-localized text is intended to resemble the source English text from which it is derived, specifically so that designers, developers, testers, and others can still navigate the application in the pseudo-localized state.

1.1.1.3. Disadvantages of Pseudo-localization

While geneerally a beneficial technique, pseudo-localization does have some disadvantages...

1.1.1.3.1. It May Produce False Positives

Because pseudo-localized text is derived purely from the source English text, any expansion process that is applied to simulate the effects of translation to other languages is approximate and not too reliable.

Expansion is determined as a percentage of the length of the source English text, but the actual expansion that will occur when translating to a specific language can vary substantially depending on the actual text being translated. Even with languages where translated text is typically longer, there can be individual cases where an English word or even sentence could be no longer when translated, or even shorter in some cases.

Therefore, the expansion process in pseudo-localization could produce false positives of issues that aren't real issues in practice. This may lead one to "fix" layout issues that don't exist in practice. In general, the more languages that an application will be translated to, the more useful the findings from pseudo-localization will be, since the variety of languages will have an aggregating effect and result in the expansion being more likely to be indicative of results for some language out of the set.

1.1.1.3.2. Primary Language Should be English

As a technique, pseudo-localization is built around the assumption that there is English text that can be used as the source for generating pseudo-localized text.

In particular, the two processes of accenting and expansion are largely predicated on the source text being English. At the very least, accenting anticipates that the source language use the Latin alphabet rather than a non-Latin script, so that alternate versions of the characters with different accents can be substituted. Expansion, on the other hand, is most valuable when the language to be used as the source for pseudo-localization is the most brief, since this will increase the number of languages that can be simulated by the expanion process (pseudo-localization can't simulate contraction, after all).

Put together, this leads to English being the most suitable language to use as the primary language from which pseudo-localized text is generated.

1.1.1.3.3. Can't Simulate Contraction

While pseudo-localization can simulate the expansion of text from translation by adding extra, easily ignorable characters without interfering with readability, there is no way to remove characters to simulate contraction without harming readability.

In contrast to languages like German, French, Spanish, Portuguese, etc., where translating from English produces text that is larger, some Asian languages that use logographic writing systems can be somewhat more compact than the equivalent English. If you want to get some sense of how much vacant space there might be in the UI when an application is translated from English to one of these more compact languages, pseudo-localization won't be coming to your rescue.

1.1.2. Pseudo-localization Features

The Uize.Loc.Pseudo module supports several pseudo-localization features, including accenting, expansion, and wrapping.

1.1.2.1. Accenting

Accenting is the process of converting Latin alphabetical characters from the ASCII character set to accented Unicode versions.

1.1.2.1.1. Accenting Enabled By Default

Accenting is enabled by default in the Uize.Loc.Pseudo.pseudoLocalize method.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.');

OUTPUT

[Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.]

What you will notice from the output in the above example is that the pseudo-localized text is still readable - all the ASCII alphabetical characters have been replaced with accented Unicode variants that are analagous to the originals.

1.1.2.1.2. Disabling Accenting

Accenting can be disabled by specifying the value false for the accent property in the options object, as shown in the example below...

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.',{accent:false});

OUTPUT

[Your_ account__ settings___ have_ been_ saved__.]

1.1.2.2. Expansion

Expansion is the process of adding extra expansion characters to simulate the expansion that typically occurs when English text is translated to languages like German, French, Spanish, Portuguese, etc.

The Uize.Loc.Pseudo.pseudoLocalize method implements expansion by adding extra characters at the end of words. Consider the following example...

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.');

OUTPUT

[Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.]

What you will notice from the above example is that each word is expanded by the addition of a suffix of "_" (underscore) characters. This is the default expansion behavior, but it can be overridden by specifying a custom expansion factor and custom expansion character.

1.1.2.2.1. How Expansion is Performed

Expansion is performed according to the following steps...

the source string is split into separate words using a word splitter regular expression
the total character count for all the words is computed
the amount of expansion characters to add is computed, by applying the expansion factor to the total character count of all the words
the computed amount of expansion characters is distrubted proportionately across all the words (a word that is twice as long as some other word will get roughly twice the number of expansion characters added as that other word)
the pseudo-localized string is constructed by concatenating the expanded words with the non-word segments
1.1.2.2.2. Expansion Factor

In order to determine how many expansion characters should be added to the source string, an expansion factor is applied to the total number of word characters in the source string.

The expansion factor is specified as a floating point number, representing the ratio of word characters in the pseudo-localized string to word characters in the source string. So, for example, an expansion factor of 2 means that the pseudo-localized string will have twice as many word characters as the source string, meaning that the length of every word will be doubled, meaning that the total length of all the words will be increased by 100% (different ways of saying the same thing, really).

EXPANSION OF 2

[Ýöûŕ____ åççöûñţ_______ šéţţîñĝš________ ĥåṽé____ ƀééñ____ šåṽéð_____.]

Similarly, an expansion factor of 1.3 means that there will be 30% more word characters in the pseudo-localized string than the source string.

EXPANSION OF 1.3

[Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.]
1.1.2.2.3. Expansion Character

When pseudo-localizing a source string, words from the source string are expanded by appending zero or more of a specific expansion character.

While the Uize.Loc.Pseudo.pseudoLocalize method uses a default expansion character, a custom expansion character can also be specified explicitly.

1.1.2.2.4. Default Expansion

Without specifying explicit values for expansion factor and expansion character. the Uize.Loc.Pseudo.pseudoLocalize method uses default expansion factor and default expansion character values.

1.1.2.2.4.1. Default Expansion Factor

When a custom expansion factor is not explicitly specified, the default value 1.3 is used for the expansion factor.

1.1.2.2.4.2. Default Expansion Character

When a custom expansion character is not explicitly specified, the default value '_' (an underscore) is used for the expansion character.

1.1.2.2.5. Custom Expansion

Custom expansion factor and custom expansion character values can be specified explicitly to achieve custom expansion.

1.1.2.2.5.1. Custom Expansion Factor

When the default expansion factor is not suitable, a custom expansion factor can be specified for the expansion property of the options object.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.',{expansion:2});

RESULT

[Ýöûŕ____ åççöûñţ_______ šéţţîñĝš________ ĥåṽé____ ƀééñ____ šåṽéð_____.]
1.1.2.2.5.2. Custom Expansion Character

When the default expansion character is not suitable, a custom expansion character can be specified for the expansionChar property of the options object.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.',{expansionChar:'~'});

RESULT

[Ýöûŕ~ åççöûñţ~~ šéţţîñĝš~~~ ĥåṽé~ ƀééñ~ šåṽéð~~.]

1.1.2.3. Wrapping

Wrapping is the process of wrapping pseudo-localized text with characters (typically square brackets) to indicate the boundaries and help to identify issues with truncation and concatenation.

1.1.2.3.1. Default Wrapper

By default, the Uize.Loc.Pseudo.pseudoLocalize method wraps all pseudo-localized text in square brackets.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.');

OUTPUT

[Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.]
1.1.2.3.2. Custom Wrapper

When the square brackets used as the default wrapper is not suitable, the Uize.Loc.Pseudo.pseudoLocalize method allows a custom wrapper to be specified using the wrapper property in the options object.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.',{wrapper:'[-  -]'});

RESULT

[- Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__. -]

When applying a custom wrapper, the wrapper string is split into two halves, the first of which is used as a prefix, and the second of which is used as a suffix.

1.1.2.3.3. No Wrapper

The wrapping process can be effectively disabled by specifying the value '' (empty string) for the wrapper property in the options object, as shown in the example below...

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('Your account settings have been saved.',{wrapper:''});

OUTPUT

Ýöûŕ_ åççöûñţ__ šéţţîñĝš___ ĥåṽé_ ƀééñ_ šåṽéð__.

1.2. Examples

The following example pages are good showcases for the Uize.Loc.Pseudo module...

Pseudo-localizer - Experiment with the technique of pseudo-localization.

SEARCH FOR EXAMPLES

Use the link below to search for example pages on the UIZE Web site that reference the Uize.Loc.Pseudo module...

SEARCH

1.3. Implementation Info

The Uize.Loc.Pseudo module defines the Uize.Loc.Pseudo package under the Uize.Loc namespace.

1.3.1. Features Introduced in This Module

The features listed in this section have been introduced in this module.

STATIC METHODS

Uize.Loc.Pseudo.accent | Uize.Loc.Pseudo.pseudoLocalize

STATIC PROPERTIES

Uize.Loc.Pseudo.moduleName | Uize.Loc.Pseudo.pathToResources

1.3.2. Features Overridden in This Module

No features have been overridden in this module.

1.3.3. Features Inherited From Other Modules

This module has no inherited features.

1.3.4. Modules Directly Under This Namespace

1.3.5. Unit Tests

The Uize.Loc.Pseudo module is unit tested by the Uize.Test.Uize.Loc.Pseudo test module.

2. Static Methods

2.1. Uize.Loc.Pseudo.accent

Returns an accented version of the specified source string, where all Latin alphabet characters are replaced with correponding accented Unicode versions of those characters.

SYNTAX

accentedSTR = Uize.Loc.Pseudo.accent (sourceSTR);

The Uize.Loc.Pseudo.accent method is useful in the process of pseudo-localization, as it provides a way to create readable versions of English source strings that are very visibly different. This can be a valuable aid during the internationalization process of an application and can help to expose those strings that are still hard-coded in the code and have not been externalized to resource files. Furthermore, accented versions of strings can also be used to test a system's support for characters outside of the standard ASCII character set.

EXAMPLE

Uize.Loc.Pseudo.accent ('This pseudo-localization thing is pretty cool!');

RESULT

Ţĥîš þšéûðö-ļöçåļîžåţîöñ ţĥîñĝ îš þŕéţţý çööļ!

NOTES

see also the Uize.Loc.Pseudo.pseudoLocalize static method

IMPLEMENTATION INFO

this feature was introduced in this module

2.2. Uize.Loc.Pseudo.pseudoLocalize

Returns a pseudo-localized version of the specified source string.

For a refresher on pseudo-localization, refer to the section What is Pseudo-localization?.

Pseudo-localize a String Using the Option Defaults

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR);

Pseudo-localize a String, Specifying Custom Options

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,optionsOBJ);

Pseudo-localize a String, But Without Accenting

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{accenting:false});

Pseudo-localize a String, But Without Expansion

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{expansion:0});

Pseudo-localize a String, Specifying a Custom Expansion Factor

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{expansion:expansionFactorNUM});

Pseudo-localize a String, Specifying a Custom Expansion Character

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (
  sourceSTR,
  {expansionChar:expansionCharSTR}
);

Pseudo-localize a String, But Without Adding a Wrapper

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{wrapper:''});

Pseudo-localize a String, Specifying a Custom Wrapper

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{wrapper:wrapperSTR});

Pseudo-localize a String, Specifying a Custom Word Splitter

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (
  sourceSTR,
  {wordSplitter:wordSplitterSTRorREGEXP}
);

2.2.1. Pseudo-localize a String Using the Option Defaults

In the simplest usage, a source string can be pseudo-localized using the option defaults by specifying the source string as the single argument.

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR);

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('This pseudo-localization thing is pretty cool!');

RESULT

[Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!]

2.2.2. Pseudo-localize a String, Specifying Custom Options

In cases where the option defaults do not satisfy the needs, a string can be pseudo-localized with custom options by speciying an options object for the optional optionsOBJ second argument.

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,optionsOBJ);

2.2.2.1. optionsOBJ

The value for the optionsOBJ parameter should be an object containing any of the following option properties, in any combination...

2.2.2.1.1. accent

A boolean, specifying whether ot not accenting of characters should be applied.

when the value null or undefined is specified for this property, its value will be defaulted to true and character accenting will be applied
when a non-nully value is specified for this property, then character accenting will be applied if the value is truthy and not applied if the value is falsy
to see an example of this option in use, see the use case Pseudo-localize a String, But Without Accenting
2.2.2.1.2. expansion

A number, specifying an expansion factor to be used when producing a pseudo-localized string from the source string.

when a number value less than or equal to 1 is specified for this property, then no expansion will take place
when a number value greater than 1 is specified for this property, then the words of the source string will be expanded by the factor specified by the expansioin property, using the expansion character specified by the companion expansionChar property (e.g. if the value 2 is specified, then the word length in the pseudo-localized string will be double that of the source string)
when the value null or undefined is specified for this property, its value will be defaulted to 1.3
when a non-number value is specified for this property, it will be coerced to a number, so specifying the string '1.5' would be equivalent to specifying the number 1.5
to see examples of this option in use, see the use cases Pseudo-localize a String, But Without Expansion and Pseudo-localize a String, Specifying a Custom Expansion Factor

For more details on the process of expansion, consult the section How Expansion is Performed.

2.2.2.1.3. expansionChar

A string, specifying a character that should be used for the expansion of words in the source string.

when the value null or undefined is specified for this property, then its value will be defaulted to the "_" (underscore) character
the character specified for this option will be repeated as necessary to expand words from the source string to produce words in the pseudo-localized string (see the section How Expansion is Performed)
to see an example of this option in use, see the use case Pseudo-localize a String, Specifying a Custom Expansion Character
2.2.2.1.4. wordSplitter

A regular expression, specifying a match expression that should be used to split a source string into words and non-words.

2.2.2.1.4.1. Default Word Splitter

When no custom word splitter is explicitly specified, the Uize.Loc.Pseudo.pseudoLocalize method uses a default word splitter that provides a basic level of support for splitting a source string into word and non-word segments.

2.2.2.1.4.2. Custom Word Splitter

When the default word splitter is not suitable, a custom word splitter can be specified for the wordSplitter property of the options object.

EXAMPLE

var
  _wordSplitterRegExpComposition = Uize.Util.RegExpComposition ({
    punctuation:/[\?!\.;,&=\-\(\)\[\]"]+/,
    number:/\d+(?:\.\d+)?/,
    whitespace:/\s+/,
    htmlTag:/<(?:.|[\r\n\f])+?>/,
    wordSplitter:/({htmlTag}|{whitespace}|{punctuation}|{number})/
  }),
  _wordSplitterRegExp = _wordSplitterRegExpComposition.get ('wordSplitter'),
  _pseudoLocalized = Uize.Loc.Pseudo.pseudoLocalize (
    '<div class="title">Account Settings</div>\n' +
    '<div class="settingsLinks">\n' +
    '  <div id="changePassword" class="settingsLink">Change Password</div>\n' +
    '  <div id="changeEmail" class="settingsLink">Change Email Address</div>\n' +
    '  <div id="billingInfo" class="settingsLink">Update Billing Info</div>\n' +
    '  <div id="shippingAddress" class="settingsLink">Shipping Address</div>\n' +
    '</div>\n',
    {
      wordSplitter:_wordSplitterRegExp,
      wrapper:''
    }
  )
;

In the above example, the Uize.Util.RegExpComposition module is being used to construct a complex word splitter regular expression with support for non-word segments comprising punctuation, numbers, whitespace, and HTML tags. We don't have to use the Uize.Util.RegExpComposition module for constructing our word splitter regular expression, but this module makes it easier to define sub-expressions and use those in other expressions.

Once the above code has been executed, the value of the _pseudoLocalized variable will be a string with the following contents...

PSEUDO-LOCALIZED STRING

<div class="title">Åççöûñţ__ Šéţţîñĝš___</div>
<div class="settingsLinks">
  <div id="changePassword" class="settingsLink">Çĥåñĝé_ Þåššŵöŕð___</div>
  <div id="changeEmail" class="settingsLink">Çĥåñĝé__ Éɱåîļ_ Åððŕéšš__</div>
  <div id="billingInfo" class="settingsLink">Ûþðåţé__ Ɓîļļîñĝ__ Îñƒö_</div>
  <div id="shippingAddress" class="settingsLink">Šĥîþþîñĝ___ Åððŕéšš__</div>
</div>

What you'll notice from the result is that none of the words that are part of the HTML tags have been pseudo-localized. Also, the non-word text that is matched by the word splitter regular expression has been ignored when computing the number of expansion characters that need to be added to the string.

2.2.2.1.5. wrapper

A string, specifying the characters that should be used to wrap the source string when performing pseudo-localization on it.

The wrapper string is split down the middle to form two parts: the opener characters (used as the prefix) and the closer characters (used as the suffix).

2.2.2.1.5.1. A Two Character Wrapper

In the simplest case, specifying a two character wrapper will result in the first character being used as the opener / prefix and the second character as the closer.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:'<>'}
);

RESULT

<Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!>
2.2.2.1.5.2. Wrappers With More Than Teo Characters

When a wrapper string with more than two characters is specified, the wrapper string is split in half to produce multi-character prefix and suffix strings.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:'[-  -]'}
);

RESULT

[- Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_! -]
2.2.2.1.5.3. An Odd Length Wrapper

When a wrapper string with an odd number of characters is specified, then the wrapper string will be split in half in such a way that the prefix string contains one more character than the suffix string.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:'<#>'}
);

RESULT

<#Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!>
2.2.2.1.5.4. An Empty Wrapper

The wrapper behavior can be disabled by specifying an empty wrapper string.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:''}
);

RESULT

Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!
2.2.2.1.5.5. The Default Wrapper

When the wrapper option is not specified, or if the values null or undefined are specified for this option, then the option is defaulted to the value '[]' to provide a "bracketing" behavior.

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize ('This pseudo-localization thing is pretty cool!');

RESULT

[Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!]

2.2.3. Pseudo-localize a String, But Without Accenting

In cases where accenting is not desired, it can be disabled by specifying the value false for the accent property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{accent:false});

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {accent:false}
);

RESULT

[This_ pseudo-localization______ thing_ is_ pretty__ cool_!]

2.2.4. Pseudo-localize a String, But Without Expansion

In cases where expansion is not desired, it can be disabled by specifying the value 0 for the expansion property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{expansion:0});

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {expansion:0}
);

RESULT

[Ţĥîš þšéûðö-ļöçåļîžåţîöñ ţĥîñĝ îš þŕéţţý çööļ!]

2.2.5. Pseudo-localize a String, Specifying a Custom Expansion Factor

When a custom expansion factor is desired, the desired expansion can be specified as a number for the expansion property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{expansion:expansionFactorNUM});

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {expansion:2}
);

RESULT

[Ţĥîš____ þšéûðö-ļöçåļîžåţîöñ___________________ ţĥîñĝ_____ îš__ þŕéţţý______ çööļ____!]

2.2.6. Pseudo-localize a String, Specifying a Custom Expansion Character

When a custom expansion character is desired, it can be specified as a string for the expansionChar property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (
  sourceSTR,
  {expansionChar:expansionCharSTR}
);

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {expansionChar:'~'}
);

RESULT

[Ţĥîš~ þšéûðö-ļöçåļîžåţîöñ~~~~~~ ţĥîñĝ~ îš~ þŕéţţý~~ çööļ~!]

2.2.7. Pseudo-localize a String, But Without Adding a Wrapper

In cases where a wrapper is not desired, this feature can be disabled by specifying the value '' (empty string) for the wrapper property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{wrapper:''});

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:''}
);

RESULT

Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!

2.2.8. Pseudo-localize a String, Specifying a Custom Wrapper

In cases where the default square brackets wrapper is not suitable, a custom wrapper can be specified using the wrapper property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (sourceSTR,{wrapper:wrapperSTR});

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  'This pseudo-localization thing is pretty cool!',
  {wrapper:'[-  -]'}
);

RESULT

[- Ţĥîš_ þšéûðö-ļöçåļîžåţîöñ______ ţĥîñĝ_ îš_ þŕéţţý__ çööļ_! -]

2.2.9. Pseudo-localize a String, Specifying a Custom Word Splitter

In cases where the default word splitter is not suitable, a custom word splitter can be specified using the wordSplitter property in the options object (as specified by the optionsOBJ parameter).

SYNTAX

pseudoLocalizedSTR = Uize.Loc.Pseudo.pseudoLocalize (
  sourceSTR,
  {wordSplitter:wordSplitterSTRorREGEXP}
);

EXAMPLE

Uize.Loc.Pseudo.pseudoLocalize (
  '<div>This <b>pseudo-localization</b> thing is pretty cool!</div>',
  {wordSplitter:/((?:<.+?>|\{[^\}]+\}|\s|[\?!\.;,&=\(\)\[\]"])+)/g}
);

RESULT

[<div>Ţĥîš_ <b>þšéûðö-ļöçåļîžåţîöñ______</b> ţĥîñĝ_ îš_ þŕéţţý__ çööļ_!</div>]

IMPLEMENTATION INFO

this feature was introduced in this module

3. Static Properties

3.1. Uize.Loc.Pseudo.moduleName

IMPLEMENTATION INFO

this feature was introduced in this module

3.2. Uize.Loc.Pseudo.pathToResources

IMPLEMENTATION INFO

this feature was introduced in this module