You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
Create a rule to find instances of unlocalized strings.
An unlocalized string is defined as:
A double-quoted string (single-quoted strings are assumed to be technical)
and, not passed to a localization function
Options:
localization-function - the string name of a localization function. For example, "localize".
localization-expression - the string text of a localization expression. For example, "nls.localize"
Examples:
// assume localization-function is "localize"
localize("Title"); // ok (localization function used)
nls.localize("Title"); // ok (localization function used)
var title = 'Title'; // ok (not double quotes)
var title = "Title"; // violation
l10n("title"); // violation
nls.l10n("Title"); // violation
// assume localization-expression is "nls.localize"
nls.localize("Title"); // ok (localization function used)
xxx.localize('Title'); // ok (not double quotes)
xxx.localize("Title"); // violation
localize("Title"); // violation
nls.l10n("Title"); // violation
The text was updated successfully, but these errors were encountered:
I implemented the new rule. The rule in named no-unexternalized-strings. I changed the name because check is about externalization. It doesn't check if the strings is actually localized (e.g. translated into a different language). The behavior is as follows:
single quoted strings and template strings are ignored.
by default all double quoted strings are treated as non externalized.
there is no default function setup.
messages passed to the localize function must be literals. (e.g. "Hello" + "World" is not allowed since it can't be handled correctly in RTL languages).
The rule can be controlled using the following object literal:
{/** list function signatures that localize a string */"signatures": string[];/** defines which argument denotes the message */"messageIndex": number;/** list signatures which are ignored when double quoted strings */"ignores": string[]}
localize("key","message");// ok (localization function used)nls.localize("key","message");// ok (localization function used)vartitle='Title';// ok (not double quotes)vartitle="Title";// violation l10n("title");// violationnls.l10n("Title");// violationvarfs=require("fs");// ok (require is in ignore list)localize("key","mes"+"sage");// violation (messages should be literals)
dbaeumer
added a commit
to dbaeumer/tslint-microsoft-contrib
that referenced
this issue
Jan 20, 2016
Create a rule to find instances of unlocalized strings.
An unlocalized string is defined as:
Options:
Examples:
The text was updated successfully, but these errors were encountered: