ilib-lint 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/AnsiConsoleFormatter.html +2 -2
- package/docs/BuiltinPlugin.html +2 -2
- package/docs/ConfigBasedFormatter.html +2 -2
- package/docs/ConfigurationProvider.html +3 -3
- package/docs/ConfigurationProvider_loadConfiguration.html +3 -3
- package/docs/DeclarativeResourceRule.html +2 -2
- package/docs/DirItem.html +2 -2
- package/docs/DirItem.js.html +2 -2
- package/docs/FileConfigurationProvider.html +5 -5
- package/docs/FileConfigurationProvider_loadConfiguration.html +3 -3
- package/docs/FileType.html +181 -5
- package/docs/FileType.js.html +48 -5
- package/docs/FixerManager.html +2 -2
- package/docs/FixerManager.js.html +4 -4
- package/docs/FolderConfigurationProvider.html +4 -4
- package/docs/FolderConfigurationProvider_loadConfiguration.html +3 -3
- package/docs/FormatterManager.html +2 -2
- package/docs/FormatterManager.js.html +5 -5
- package/docs/LineParser.html +78 -4
- package/docs/LineRegexpChecker.html +2 -2
- package/docs/LintableFile.html +1099 -0
- package/docs/LintableFile.js.html +330 -0
- package/docs/ParserManager.html +167 -5
- package/docs/ParserManager.js.html +17 -5
- package/docs/PluginManager.html +10 -10
- package/docs/PluginManager.js.html +120 -92
- package/docs/Project.html +24 -24
- package/docs/Project.js.html +125 -88
- package/docs/ReleaseNotes.md +17 -0
- package/docs/ResourceCompleteness.html +2 -2
- package/docs/ResourceDNTTerms.html +10 -10
- package/docs/ResourceEdgeWhitespace.html +2 -2
- package/docs/ResourceICUPluralTranslation.html +2 -2
- package/docs/ResourceICUPlurals.html +2 -2
- package/docs/ResourceMatcher.html +2 -2
- package/docs/ResourceNoTranslation.html +2 -2
- package/docs/ResourceQuoteStyle.html +342 -6
- package/docs/ResourceRule.html +2 -2
- package/docs/ResourceSourceChecker.html +2 -2
- package/docs/ResourceSourceICUPluralCategories.html +2 -2
- package/docs/ResourceSourceICUPluralParams.html +2 -2
- package/docs/ResourceSourceICUPluralSyntax.html +2 -2
- package/docs/ResourceSourceICUUnexplainedParams.html +2 -2
- package/docs/ResourceStateChecker.html +2 -2
- package/docs/ResourceTargetChecker.html +2 -2
- package/docs/ResourceUniqueKeys.html +4 -4
- package/docs/ResultComparator.js.html +2 -2
- package/docs/RuleManager.html +2 -2
- package/docs/RuleManager.js.html +4 -4
- package/docs/RuleSet.html +142 -5
- package/docs/RuleSet.js.html +13 -2
- package/docs/SourceRegexpChecker.html +2 -2
- package/docs/StringFixCommand_StringFixCommand.html +2 -2
- package/docs/StringParser.html +4 -4
- package/docs/XliffParser.html +79 -5
- package/docs/config_Configuration.js.html +21 -3
- package/docs/config_ConfigurationProvider.js.html +21 -3
- package/docs/config_default.js.html +21 -3
- package/docs/formatters_AnsiConsoleFormatter.js.html +4 -4
- package/docs/formatters_ConfigBasedFormatter.js.html +4 -4
- package/docs/global.html +1090 -143
- package/docs/ilibLint.md +0 -0
- package/docs/index.html +2 -2
- package/docs/plugins_BuiltinPlugin.js.html +5 -5
- package/docs/plugins_LineParser.js.html +10 -10
- package/docs/plugins_XliffParser.js.html +18 -17
- package/docs/plugins_string_StringFix.js.html +4 -4
- package/docs/plugins_string_StringFixCommand.js.html +2 -2
- package/docs/plugins_string_StringFixer.js.html +4 -4
- package/docs/plugins_string_StringParser.js.html +8 -9
- package/docs/resource-xml.md +58 -0
- package/docs/rules_DeclarativeResourceRule.js.html +2 -2
- package/docs/rules_LineRegexpChecker.js.html +5 -5
- package/docs/rules_ResourceCompleteness.js.html +4 -4
- package/docs/rules_ResourceDNTTerms.js.html +4 -5
- package/docs/rules_ResourceEdgeWhitespace.js.html +4 -4
- package/docs/rules_ResourceICUPluralTranslation.js.html +4 -4
- package/docs/rules_ResourceICUPlurals.js.html +3 -3
- package/docs/rules_ResourceMatcher.js.html +3 -3
- package/docs/rules_ResourceNoTranslation.js.html +4 -4
- package/docs/rules_ResourceQuoteStyle.js.html +227 -122
- package/docs/rules_ResourceRule.js.html +4 -4
- package/docs/rules_ResourceSourceChecker.js.html +4 -4
- package/docs/rules_ResourceSourceICUPluralCategories.js.html +4 -4
- package/docs/rules_ResourceSourceICUPluralParams.js.html +4 -4
- package/docs/rules_ResourceSourceICUPluralSyntax.js.html +4 -4
- package/docs/rules_ResourceSourceICUUnexplainedParams.js.html +4 -4
- package/docs/rules_ResourceStateChecker.js.html +4 -4
- package/docs/rules_ResourceTargetChecker.js.html +4 -4
- package/docs/rules_ResourceUniqueKeys.js.html +4 -5
- package/docs/rules_SourceRegexpChecker.js.html +5 -5
- package/docs/rules_utils.js.html +2 -2
- package/package.json +13 -12
- package/src/LintableFile.js +7 -1
- package/src/formatters/AnsiConsoleFormatter.js +2 -1
- package/src/plugins/BuiltinPlugin.js +4 -1
- package/src/rules/ResourceXML.js +244 -0
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
<nav >
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnsiConsoleFormatter.html">AnsiConsoleFormatter</a><ul class='methods'><li data-type='method'><a href="AnsiConsoleFormatter.html#format">format</a></li></ul></li><li><a href="BuiltinPlugin.html">BuiltinPlugin</a><ul class='methods'><li data-type='method'><a href="BuiltinPlugin.html#getFormatters">getFormatters</a></li><li data-type='method'><a href="BuiltinPlugin.html#getParsers">getParsers</a></li><li data-type='method'><a href="BuiltinPlugin.html#getRuleSets">getRuleSets</a></li><li data-type='method'><a href="BuiltinPlugin.html#getRules">getRules</a></li></ul></li><li><a href="ConfigBasedFormatter.html">ConfigBasedFormatter</a><ul class='methods'><li data-type='method'><a href="ConfigBasedFormatter.html#format">format</a></li></ul></li><li><a href="DeclarativeResourceRule.html">DeclarativeResourceRule</a><ul class='methods'><li data-type='method'><a href="DeclarativeResourceRule.html#checkString">checkString</a></li><li data-type='method'><a href="DeclarativeResourceRule.html#matchString">matchString</a></li></ul></li><li><a href="DirItem.html">DirItem</a><ul class='methods'><li data-type='method'><a href="DirItem.html#findIssues">findIssues</a></li><li data-type='method'><a href="DirItem.html#getFilePath">getFilePath</a></li><li data-type='method'><a href="DirItem.html#parse">parse</a></li></ul></li><li><a href="FileConfigurationProvider.html">FileConfigurationProvider</a><ul class='methods'><li data-type='method'><a href="FileConfigurationProvider.html#loadJsConfiguration">loadJsConfiguration</a></li><li data-type='method'><a href="FileConfigurationProvider.html#loadJsonConfiguration">loadJsonConfiguration</a></li></ul></li><li><a href="FileType.html">FileType</a><ul class='methods'><li data-type='method'><a href="FileType.html#getRuleSetNames">getRuleSetNames</a></li><li data-type='method'><a href="FileType.html#getRules">getRules</a></li></ul></li><li><a href="FixerManager.html">FixerManager</a><ul class='methods'><li data-type='method'><a href="FixerManager.html#add">add</a></li><li data-type='method'><a href="FixerManager.html#get">get</a></li><li data-type='method'><a href="FixerManager.html#size">size</a></li></ul></li><li><a href="FolderConfigurationProvider.html">FolderConfigurationProvider</a><ul class='methods'><li data-type='method'><a href="FolderConfigurationProvider.html#hasConfigurationFile">hasConfigurationFile</a></li></ul></li><li><a href="FormatterManager.html">FormatterManager</a><ul class='methods'><li data-type='method'><a href="FormatterManager.html#add">add</a></li><li data-type='method'><a href="FormatterManager.html#get">get</a></li><li data-type='method'><a href="FormatterManager.html#getDescriptions">getDescriptions</a></li><li data-type='method'><a href="FormatterManager.html#size">size</a></li></ul></li><li><a href="LineParser.html">LineParser</a><ul class='methods'><li data-type='method'><a href="LineParser.html#parse">parse</a></li></ul></li><li><a href="LineRegexpChecker.html">LineRegexpChecker</a><ul class='methods'><li data-type='method'><a href="LineRegexpChecker.html#match">match</a></li></ul></li><li><a href="ParserManager.html">ParserManager</a><ul class='methods'><li data-type='method'><a href="ParserManager.html#add">add</a></li><li data-type='method'><a href="ParserManager.html#get">get</a></li><li data-type='method'><a href="ParserManager.html#getDescriptions">getDescriptions</a></li></ul></li><li><a href="PluginManager.html">PluginManager</a><ul class='methods'><li data-type='method'><a href="PluginManager.html#add">add</a></li><li data-type='method'><a href="PluginManager.html#getFixerManager">getFixerManager</a></li><li data-type='method'><a href="PluginManager.html#getFormatterManager">getFormatterManager</a></li><li data-type='method'><a href="PluginManager.html#getParserManager">getParserManager</a></li><li data-type='method'><a href="PluginManager.html#getRuleManager">getRuleManager</a></li><li data-type='method'><a href="PluginManager.html#getRuleSet">getRuleSet</a></li><li data-type='method'><a href="PluginManager.html#load">load</a></li></ul></li><li><a href="Project.html">Project</a><ul class='methods'><li data-type='method'><a href="Project.html#add">add</a></li><li data-type='method'><a href="Project.html#findIssues">findIssues</a></li><li data-type='method'><a href="Project.html#get">get</a></li><li data-type='method'><a href="Project.html#getExcludes">getExcludes</a></li><li data-type='method'><a href="Project.html#getFileType">getFileType</a></li><li data-type='method'><a href="Project.html#getFileTypeForPath">getFileTypeForPath</a></li><li data-type='method'><a href="Project.html#getFixerManager">getFixerManager</a></li><li data-type='method'><a href="Project.html#getIncludes">getIncludes</a></li><li data-type='method'><a href="Project.html#getLocales">getLocales</a></li><li data-type='method'><a href="Project.html#getName">getName</a></li><li data-type='method'><a href="Project.html#getOptions">getOptions</a></li><li data-type='method'><a href="Project.html#getParserManager">getParserManager</a></li><li data-type='method'><a href="Project.html#getPluginManager">getPluginManager</a></li><li data-type='method'><a href="Project.html#getRoot">getRoot</a></li><li data-type='method'><a href="Project.html#getRuleManager">getRuleManager</a></li><li data-type='method'><a href="Project.html#getScore">getScore</a></li><li data-type='method'><a href="Project.html#getSourceLocale">getSourceLocale</a></li><li data-type='method'><a href="Project.html#init">init</a></li><li data-type='method'><a href="Project.html#run">run</a></li><li data-type='method'><a href="Project.html#scan">scan</a></li></ul></li><li><a href="ResourceCompleteness.html">ResourceCompleteness</a><ul class='methods'><li data-type='method'><a href="ResourceCompleteness.html#matchString">matchString</a></li></ul></li><li><a href="ResourceDNTTerms.html">ResourceDNTTerms</a><ul class='methods'><li data-type='method'><a href="ResourceDNTTerms.html#matchString">matchString</a></li><li data-type='method'><a href="ResourceDNTTerms.html#.parseTermsFromJsonFile">parseTermsFromJsonFile</a></li><li data-type='method'><a href="ResourceDNTTerms.html#.parseTermsFromTxtFile">parseTermsFromTxtFile</a></li></ul></li><li><a href="ResourceEdgeWhitespace.html">ResourceEdgeWhitespace</a><ul class='methods'><li data-type='method'><a href="ResourceEdgeWhitespace.html#matchString">matchString</a></li></ul></li><li><a href="ResourceICUPluralTranslation.html">ResourceICUPluralTranslation</a><ul class='methods'><li data-type='method'><a href="ResourceICUPluralTranslation.html#matchString">matchString</a></li></ul></li><li><a href="ResourceICUPlurals.html">ResourceICUPlurals</a></li><li><a href="ResourceMatcher.html">ResourceMatcher</a><ul class='methods'><li data-type='method'><a href="ResourceMatcher.html#checkString">checkString</a></li></ul></li><li><a href="ResourceNoTranslation.html">ResourceNoTranslation</a><ul class='methods'><li data-type='method'><a href="ResourceNoTranslation.html#matchString">matchString</a></li></ul></li><li><a href="ResourceQuoteStyle.html">ResourceQuoteStyle</a><ul class='methods'><li data-type='method'><a href="ResourceQuoteStyle.html#matchString">matchString</a></li></ul></li><li><a href="ResourceRule.html">ResourceRule</a><ul class='methods'><li data-type='method'><a href="ResourceRule.html#getRuleType">getRuleType</a></li><li data-type='method'><a href="ResourceRule.html#match">match</a></li><li data-type='method'><a href="ResourceRule.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceChecker.html">ResourceSourceChecker</a><ul class='methods'><li data-type='method'><a href="ResourceSourceChecker.html#checkString">checkString</a></li></ul></li><li><a href="ResourceSourceICUPluralCategories.html">ResourceSourceICUPluralCategories</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralCategories.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUPluralParams.html">ResourceSourceICUPluralParams</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralParams.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUPluralSyntax.html">ResourceSourceICUPluralSyntax</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralSyntax.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUUnexplainedParams.html">ResourceSourceICUUnexplainedParams</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUUnexplainedParams.html#matchString">matchString</a></li></ul></li><li><a href="ResourceStateChecker.html">ResourceStateChecker</a><ul class='methods'><li data-type='method'><a href="ResourceStateChecker.html#match">match</a></li></ul></li><li><a href="ResourceTargetChecker.html">ResourceTargetChecker</a><ul class='methods'><li data-type='method'><a href="ResourceTargetChecker.html#checkString">checkString</a></li></ul></li><li><a href="ResourceUniqueKeys.html">ResourceUniqueKeys</a><ul class='methods'><li data-type='method'><a href="ResourceUniqueKeys.html#match">match</a></li></ul></li><li><a href="RuleManager.html">RuleManager</a><ul class='methods'><li data-type='method'><a href="RuleManager.html#add">add</a></li><li data-type='method'><a href="RuleManager.html#addRuleSetDefinition">addRuleSetDefinition</a></li><li data-type='method'><a href="RuleManager.html#addRuleSetDefinitions">addRuleSetDefinitions</a></li><li data-type='method'><a href="RuleManager.html#get">get</a></li><li data-type='method'><a href="RuleManager.html#getDescriptions">getDescriptions</a></li><li data-type='method'><a href="RuleManager.html#getRuleSetDefinition">getRuleSetDefinition</a></li><li data-type='method'><a href="RuleManager.html#getRuleSetDefinitions">getRuleSetDefinitions</a></li><li data-type='method'><a href="RuleManager.html#getRules">getRules</a></li><li data-type='method'><a href="RuleManager.html#size">size</a></li><li data-type='method'><a href="RuleManager.html#sizeRuleSetDefinitions">sizeRuleSetDefinitions</a></li></ul></li><li><a href="RuleSet.html">RuleSet</a><ul class='methods'><li data-type='method'><a href="RuleSet.html#add">add</a></li><li data-type='method'><a href="RuleSet.html#addRule">addRule</a></li><li data-type='method'><a href="RuleSet.html#getRule">getRule</a></li><li data-type='method'><a href="RuleSet.html#getRules">getRules</a></li><li data-type='method'><a href="RuleSet.html#getSize">getSize</a></li></ul></li><li><a href="SourceFile.html">SourceFile</a><ul class='methods'><li data-type='method'><a href="SourceFile.html#findIssues">findIssues</a></li><li data-type='method'><a href="SourceFile.html#getLocaleFromPath">getLocaleFromPath</a></li><li data-type='method'><a href="SourceFile.html#parse">parse</a></li></ul></li><li><a href="SourceRegexpChecker.html">SourceRegexpChecker</a><ul class='methods'><li data-type='method'><a href="SourceRegexpChecker.html#match">match</a></li></ul></li><li><a href="StringFixCommand_StringFixCommand.html">StringFixCommand</a></li><li><a href="StringParser.html">StringParser</a><ul class='methods'><li data-type='method'><a href="StringParser.html#parse">parse</a></li><li data-type='method'><a href="StringParser.html#write">write</a></li></ul></li><li><a href="XliffParser.html">XliffParser</a><ul class='methods'><li data-type='method'><a href="XliffParser.html#parse">parse</a></li></ul></li></ul><h3>Interfaces</h3><ul><li><a href="ConfigurationProvider.html">ConfigurationProvider</a></li><li><a href="ConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li><li><a href="FileConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li><li><a href="FolderConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li></ul><h3>Global</h3><ul><li><a href="global.html#DeclarativeRuleTypes">DeclarativeRuleTypes</a></li><li><a href="global.html#ResultComparator">ResultComparator</a></li><li><a href="global.html#concatIntlAstText">concatIntlAstText</a></li><li><a href="global.html#defaultConfiguration">defaultConfiguration</a></li><li><a href="global.html#typeMap">typeMap</a></li></ul>
|
|
32
|
+
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="AnsiConsoleFormatter.html">AnsiConsoleFormatter</a><ul class='methods'><li data-type='method'><a href="AnsiConsoleFormatter.html#format">format</a></li></ul></li><li><a href="BuiltinPlugin.html">BuiltinPlugin</a><ul class='methods'><li data-type='method'><a href="BuiltinPlugin.html#getFormatters">getFormatters</a></li><li data-type='method'><a href="BuiltinPlugin.html#getParsers">getParsers</a></li><li data-type='method'><a href="BuiltinPlugin.html#getRuleSets">getRuleSets</a></li><li data-type='method'><a href="BuiltinPlugin.html#getRules">getRules</a></li></ul></li><li><a href="ConfigBasedFormatter.html">ConfigBasedFormatter</a><ul class='methods'><li data-type='method'><a href="ConfigBasedFormatter.html#format">format</a></li></ul></li><li><a href="DeclarativeResourceRule.html">DeclarativeResourceRule</a><ul class='methods'><li data-type='method'><a href="DeclarativeResourceRule.html#checkString">checkString</a></li><li data-type='method'><a href="DeclarativeResourceRule.html#matchString">matchString</a></li></ul></li><li><a href="DirItem.html">DirItem</a><ul class='methods'><li data-type='method'><a href="DirItem.html#findIssues">findIssues</a></li><li data-type='method'><a href="DirItem.html#getFilePath">getFilePath</a></li><li data-type='method'><a href="DirItem.html#parse">parse</a></li></ul></li><li><a href="FileConfigurationProvider.html">FileConfigurationProvider</a><ul class='methods'><li data-type='method'><a href="FileConfigurationProvider.html#loadJsConfiguration">loadJsConfiguration</a></li><li data-type='method'><a href="FileConfigurationProvider.html#loadJsonConfiguration">loadJsonConfiguration</a></li></ul></li><li><a href="FileType.html">FileType</a><ul class='methods'><li data-type='method'><a href="FileType.html#getParserClasses">getParserClasses</a></li><li data-type='method'><a href="FileType.html#getRuleSetNames">getRuleSetNames</a></li><li data-type='method'><a href="FileType.html#getRules">getRules</a></li></ul></li><li><a href="FixerManager.html">FixerManager</a><ul class='methods'><li data-type='method'><a href="FixerManager.html#add">add</a></li><li data-type='method'><a href="FixerManager.html#get">get</a></li><li data-type='method'><a href="FixerManager.html#size">size</a></li></ul></li><li><a href="FolderConfigurationProvider.html">FolderConfigurationProvider</a><ul class='methods'><li data-type='method'><a href="FolderConfigurationProvider.html#hasConfigurationFile">hasConfigurationFile</a></li></ul></li><li><a href="FormatterManager.html">FormatterManager</a><ul class='methods'><li data-type='method'><a href="FormatterManager.html#add">add</a></li><li data-type='method'><a href="FormatterManager.html#get">get</a></li><li data-type='method'><a href="FormatterManager.html#getDescriptions">getDescriptions</a></li><li data-type='method'><a href="FormatterManager.html#size">size</a></li></ul></li><li><a href="LineParser.html">LineParser</a><ul class='methods'><li data-type='method'><a href="LineParser.html#parse">parse</a></li></ul></li><li><a href="LineRegexpChecker.html">LineRegexpChecker</a><ul class='methods'><li data-type='method'><a href="LineRegexpChecker.html#match">match</a></li></ul></li><li><a href="LintableFile.html">LintableFile</a><ul class='methods'><li data-type='method'><a href="LintableFile.html#findIssues">findIssues</a></li><li data-type='method'><a href="LintableFile.html#getIRs">getIRs</a></li><li data-type='method'><a href="LintableFile.html#getLocaleFromPath">getLocaleFromPath</a></li><li data-type='method'><a href="LintableFile.html#getStats">getStats</a></li><li data-type='method'><a href="LintableFile.html#parse">parse</a></li></ul></li><li><a href="ParserManager.html">ParserManager</a><ul class='methods'><li data-type='method'><a href="ParserManager.html#add">add</a></li><li data-type='method'><a href="ParserManager.html#get">get</a></li><li data-type='method'><a href="ParserManager.html#getByName">getByName</a></li><li data-type='method'><a href="ParserManager.html#getDescriptions">getDescriptions</a></li></ul></li><li><a href="PluginManager.html">PluginManager</a><ul class='methods'><li data-type='method'><a href="PluginManager.html#add">add</a></li><li data-type='method'><a href="PluginManager.html#getFixerManager">getFixerManager</a></li><li data-type='method'><a href="PluginManager.html#getFormatterManager">getFormatterManager</a></li><li data-type='method'><a href="PluginManager.html#getParserManager">getParserManager</a></li><li data-type='method'><a href="PluginManager.html#getRuleManager">getRuleManager</a></li><li data-type='method'><a href="PluginManager.html#getRuleSet">getRuleSet</a></li><li data-type='method'><a href="PluginManager.html#load">load</a></li></ul></li><li><a href="Project.html">Project</a><ul class='methods'><li data-type='method'><a href="Project.html#add">add</a></li><li data-type='method'><a href="Project.html#findIssues">findIssues</a></li><li data-type='method'><a href="Project.html#get">get</a></li><li data-type='method'><a href="Project.html#getExcludes">getExcludes</a></li><li data-type='method'><a href="Project.html#getFileType">getFileType</a></li><li data-type='method'><a href="Project.html#getFileTypeForPath">getFileTypeForPath</a></li><li data-type='method'><a href="Project.html#getFixerManager">getFixerManager</a></li><li data-type='method'><a href="Project.html#getIncludes">getIncludes</a></li><li data-type='method'><a href="Project.html#getLocales">getLocales</a></li><li data-type='method'><a href="Project.html#getName">getName</a></li><li data-type='method'><a href="Project.html#getOptions">getOptions</a></li><li data-type='method'><a href="Project.html#getParserManager">getParserManager</a></li><li data-type='method'><a href="Project.html#getPluginManager">getPluginManager</a></li><li data-type='method'><a href="Project.html#getRoot">getRoot</a></li><li data-type='method'><a href="Project.html#getRuleManager">getRuleManager</a></li><li data-type='method'><a href="Project.html#getScore">getScore</a></li><li data-type='method'><a href="Project.html#getSourceLocale">getSourceLocale</a></li><li data-type='method'><a href="Project.html#init">init</a></li><li data-type='method'><a href="Project.html#run">run</a></li><li data-type='method'><a href="Project.html#scan">scan</a></li></ul></li><li><a href="ResourceCompleteness.html">ResourceCompleteness</a><ul class='methods'><li data-type='method'><a href="ResourceCompleteness.html#matchString">matchString</a></li></ul></li><li><a href="ResourceDNTTerms.html">ResourceDNTTerms</a><ul class='methods'><li data-type='method'><a href="ResourceDNTTerms.html#matchString">matchString</a></li><li data-type='method'><a href="ResourceDNTTerms.html#.parseTermsFromJsonFile">parseTermsFromJsonFile</a></li><li data-type='method'><a href="ResourceDNTTerms.html#.parseTermsFromTxtFile">parseTermsFromTxtFile</a></li></ul></li><li><a href="ResourceEdgeWhitespace.html">ResourceEdgeWhitespace</a><ul class='methods'><li data-type='method'><a href="ResourceEdgeWhitespace.html#matchString">matchString</a></li></ul></li><li><a href="ResourceICUPluralTranslation.html">ResourceICUPluralTranslation</a><ul class='methods'><li data-type='method'><a href="ResourceICUPluralTranslation.html#matchString">matchString</a></li></ul></li><li><a href="ResourceICUPlurals.html">ResourceICUPlurals</a></li><li><a href="ResourceMatcher.html">ResourceMatcher</a><ul class='methods'><li data-type='method'><a href="ResourceMatcher.html#checkString">checkString</a></li></ul></li><li><a href="ResourceNoTranslation.html">ResourceNoTranslation</a><ul class='methods'><li data-type='method'><a href="ResourceNoTranslation.html#matchString">matchString</a></li></ul></li><li><a href="ResourceQuoteStyle.html">ResourceQuoteStyle</a><ul class='methods'><li data-type='method'><a href="ResourceQuoteStyle.html#matchString">matchString</a></li></ul></li><li><a href="ResourceRule.html">ResourceRule</a><ul class='methods'><li data-type='method'><a href="ResourceRule.html#getRuleType">getRuleType</a></li><li data-type='method'><a href="ResourceRule.html#match">match</a></li><li data-type='method'><a href="ResourceRule.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceChecker.html">ResourceSourceChecker</a><ul class='methods'><li data-type='method'><a href="ResourceSourceChecker.html#checkString">checkString</a></li></ul></li><li><a href="ResourceSourceICUPluralCategories.html">ResourceSourceICUPluralCategories</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralCategories.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUPluralParams.html">ResourceSourceICUPluralParams</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralParams.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUPluralSyntax.html">ResourceSourceICUPluralSyntax</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUPluralSyntax.html#matchString">matchString</a></li></ul></li><li><a href="ResourceSourceICUUnexplainedParams.html">ResourceSourceICUUnexplainedParams</a><ul class='methods'><li data-type='method'><a href="ResourceSourceICUUnexplainedParams.html#matchString">matchString</a></li></ul></li><li><a href="ResourceStateChecker.html">ResourceStateChecker</a><ul class='methods'><li data-type='method'><a href="ResourceStateChecker.html#match">match</a></li></ul></li><li><a href="ResourceTargetChecker.html">ResourceTargetChecker</a><ul class='methods'><li data-type='method'><a href="ResourceTargetChecker.html#checkString">checkString</a></li></ul></li><li><a href="ResourceUniqueKeys.html">ResourceUniqueKeys</a><ul class='methods'><li data-type='method'><a href="ResourceUniqueKeys.html#match">match</a></li></ul></li><li><a href="RuleManager.html">RuleManager</a><ul class='methods'><li data-type='method'><a href="RuleManager.html#add">add</a></li><li data-type='method'><a href="RuleManager.html#addRuleSetDefinition">addRuleSetDefinition</a></li><li data-type='method'><a href="RuleManager.html#addRuleSetDefinitions">addRuleSetDefinitions</a></li><li data-type='method'><a href="RuleManager.html#get">get</a></li><li data-type='method'><a href="RuleManager.html#getDescriptions">getDescriptions</a></li><li data-type='method'><a href="RuleManager.html#getRuleSetDefinition">getRuleSetDefinition</a></li><li data-type='method'><a href="RuleManager.html#getRuleSetDefinitions">getRuleSetDefinitions</a></li><li data-type='method'><a href="RuleManager.html#getRules">getRules</a></li><li data-type='method'><a href="RuleManager.html#size">size</a></li><li data-type='method'><a href="RuleManager.html#sizeRuleSetDefinitions">sizeRuleSetDefinitions</a></li></ul></li><li><a href="RuleSet.html">RuleSet</a><ul class='methods'><li data-type='method'><a href="RuleSet.html#add">add</a></li><li data-type='method'><a href="RuleSet.html#addRule">addRule</a></li><li data-type='method'><a href="RuleSet.html#getRule">getRule</a></li><li data-type='method'><a href="RuleSet.html#getRules">getRules</a></li><li data-type='method'><a href="RuleSet.html#getSize">getSize</a></li><li data-type='method'><a href="RuleSet.html#removeRule">removeRule</a></li></ul></li><li><a href="SourceRegexpChecker.html">SourceRegexpChecker</a><ul class='methods'><li data-type='method'><a href="SourceRegexpChecker.html#match">match</a></li></ul></li><li><a href="StringFixCommand_StringFixCommand.html">StringFixCommand</a></li><li><a href="StringParser.html">StringParser</a><ul class='methods'><li data-type='method'><a href="StringParser.html#parse">parse</a></li><li data-type='method'><a href="StringParser.html#write">write</a></li></ul></li><li><a href="XliffParser.html">XliffParser</a><ul class='methods'><li data-type='method'><a href="XliffParser.html#parse">parse</a></li></ul></li></ul><h3>Interfaces</h3><ul><li><a href="ConfigurationProvider.html">ConfigurationProvider</a></li><li><a href="ConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li><li><a href="FileConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li><li><a href="FolderConfigurationProvider_loadConfiguration.html">loadConfiguration</a></li></ul><h3>Global</h3><ul><li><a href="global.html#DeclarativeRuleTypes">DeclarativeRuleTypes</a></li><li><a href="global.html#ResultComparator">ResultComparator</a></li><li><a href="global.html#concatIntlAstText">concatIntlAstText</a></li><li><a href="global.html#defaultConfiguration">defaultConfiguration</a></li><li><a href="global.html#severity">severity</a></li><li><a href="global.html#typeMap">typeMap</a></li></ul>
|
|
33
33
|
|
|
34
34
|
</nav>
|
|
35
35
|
|
|
@@ -65,21 +65,70 @@
|
|
|
65
65
|
*/
|
|
66
66
|
|
|
67
67
|
import LocaleInfo from 'ilib-localeinfo';
|
|
68
|
-
import
|
|
69
|
-
import { Rule, Result } from 'i18nlint-common';
|
|
68
|
+
import { Result } from 'ilib-lint-common';
|
|
70
69
|
|
|
71
70
|
import ResourceRule from './ResourceRule.js';
|
|
72
71
|
|
|
73
|
-
|
|
74
|
-
let regExpsCache = {};
|
|
72
|
+
/** @ignore @typedef {import("ilib-tools-common").Resource} Resource */
|
|
75
73
|
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
/**
|
|
75
|
+
* @typedef BaseRegExpCollection
|
|
76
|
+
* @type {object}
|
|
77
|
+
* @prop {string} quoteStart
|
|
78
|
+
* @prop {string} quoteStartAlt
|
|
79
|
+
* @prop {string} quoteEnd
|
|
80
|
+
* @prop {string} quoteEndAlt
|
|
81
|
+
* @prop {RegExp} quotesNative
|
|
82
|
+
* @prop {RegExp} quotesNativeAlt
|
|
83
|
+
*
|
|
84
|
+
* @typedef {BaseRegExpCollection} SourceRegExpCollection
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* @typedef ExtendedRegExpCollection
|
|
89
|
+
* @type {object}
|
|
90
|
+
* @prop {RegExp} quotesAll
|
|
91
|
+
* @prop {RegExp} quotesAllAlt
|
|
92
|
+
* @prop {string} nonQuoteChars
|
|
93
|
+
* @prop {string} nonQuoteCharsAlt
|
|
94
|
+
*
|
|
95
|
+
* @typedef {BaseRegExpCollection & ExtendedRegExpCollection} TargetRegExpCollection
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* @typedef RegExpCollectionForLocale
|
|
100
|
+
* @type {object}
|
|
101
|
+
* @prop {RegExp} quotesAscii
|
|
102
|
+
* @prop {RegExp} quotesAsciiAlt
|
|
103
|
+
* @prop {SourceRegExpCollection} source
|
|
104
|
+
* @prop {TargetRegExpCollection} target
|
|
105
|
+
*/
|
|
78
106
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
107
|
+
let /** @type {{[locale: string]: LocaleInfo}} */ LICache = {};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* @typedef ModeLocaleOnly
|
|
111
|
+
* @type {"localeOnly"}
|
|
112
|
+
* Allow only localized quotes in the target string. This also sets default result severity to "error".
|
|
113
|
+
*/
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* @typedef Severity
|
|
117
|
+
* @type {("error"|"warning"|"suggestion")}
|
|
118
|
+
* Result severity.
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* @typedef Modes
|
|
123
|
+
* @type {ModeLocaleOnly}
|
|
124
|
+
* One-param rule configuration.
|
|
125
|
+
*/
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @typedef Configuration
|
|
129
|
+
* @type {Modes}
|
|
130
|
+
* Parameters that can be set through rule configuration file.
|
|
131
|
+
*/
|
|
83
132
|
|
|
84
133
|
/**
|
|
85
134
|
* @class Represent an ilib-lint rule.
|
|
@@ -87,183 +136,239 @@ const quotesAsciiAlt = new RegExp(`((^|\\W)'\\s?[\\p{Letter}\\{]|[a-rt-zA-RT-Z\\
|
|
|
87
136
|
class ResourceQuoteStyle extends ResourceRule {
|
|
88
137
|
/**
|
|
89
138
|
* Make a new rule instance.
|
|
90
|
-
*
|
|
139
|
+
*
|
|
140
|
+
* @param {object} [options]
|
|
141
|
+
* @param {string} [options.sourceLocale]
|
|
142
|
+
* @param {Configuration} [options.param]
|
|
91
143
|
*/
|
|
92
144
|
constructor(options) {
|
|
93
|
-
super(options);
|
|
145
|
+
super(options ?? {});
|
|
94
146
|
this.name = "resource-quote-style";
|
|
95
147
|
this.description = "Ensure that the proper quote characters are used in translated resources";
|
|
96
148
|
this.sourceLocale = (options && options.sourceLocale) || "en-US";
|
|
97
|
-
|
|
149
|
+
this.link = "https://github.com/ilib-js/ilib-lint/blob/main/docs/resource-quote-style.md";
|
|
150
|
+
|
|
151
|
+
if (options?.param === "localeOnly") {
|
|
98
152
|
// only localized quotes are allowed in the target string
|
|
99
153
|
this.localeOnly = true;
|
|
100
154
|
}
|
|
101
|
-
|
|
155
|
+
|
|
102
156
|
if (!this.skipLocales) {
|
|
103
157
|
this.skipLocales = new Set();
|
|
104
158
|
}
|
|
105
|
-
|
|
159
|
+
|
|
106
160
|
[
|
|
107
161
|
"sv", // According to the MS Style guidelines, quotes are usually not required in Swedish when the source English text contains quotes
|
|
108
162
|
"it", // Based on feedback from linguists quotes in Italian are not required to be the guillemets, even though CLDR says so
|
|
109
|
-
].forEach(locale => this.skipLocales.add(locale));
|
|
163
|
+
].forEach(locale => this.skipLocales.add(locale));
|
|
110
164
|
}
|
|
111
165
|
|
|
112
166
|
/**
|
|
113
167
|
* @private
|
|
168
|
+
* @param {string} src
|
|
169
|
+
* @param {string} tar
|
|
170
|
+
* @param {Resource} resource
|
|
171
|
+
* @param {string} file
|
|
172
|
+
* @param {string} locale
|
|
114
173
|
*/
|
|
115
|
-
checkString(src, tar, resource, file, locale
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const asciiMatches = src.match(quotesAscii);
|
|
126
|
-
const asciiMatchesAlt = src.match(quotesAsciiAlt);
|
|
127
|
-
const nativeMatches = src.match(regExps.source.quotesNative);
|
|
128
|
-
const nativeMatchesAlt = src.match(regExps.source.quotesNativeAlt);
|
|
129
|
-
|
|
130
|
-
// see if we need to check the target
|
|
131
|
-
if (!asciiMatches && !asciiMatchesAlt && !nativeMatches && !nativeMatchesAlt) return;
|
|
132
|
-
|
|
133
|
-
let re1, re2;
|
|
174
|
+
checkString(src, tar, resource, file, locale) {
|
|
175
|
+
const regExps = this.getRegExps(locale);
|
|
176
|
+
|
|
177
|
+
const sourceStyle = {
|
|
178
|
+
ascii: regExps.quotesAscii.test(src),
|
|
179
|
+
asciiAlt: regExps.quotesAsciiAlt.test(src),
|
|
180
|
+
native: regExps.source.quotesNative.test(src),
|
|
181
|
+
nativeAlt: regExps.source.quotesNativeAlt.test(src)
|
|
182
|
+
}
|
|
134
183
|
|
|
135
184
|
// used in results to show what the expected quote style is
|
|
136
|
-
const
|
|
137
|
-
`${regExps.target.quoteStart}text${regExps.target.quoteEnd}` :
|
|
138
|
-
`${regExps.target.quoteStartAlt}text${regExps.target.quoteEndAlt}`;
|
|
139
|
-
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
185
|
+
const targetQuoteStyleExample = (sourceStyle.ascii || sourceStyle.native) ?
|
|
186
|
+
`${regExps.target.quoteStart[0]}text${regExps.target.quoteEnd[0]}` :
|
|
187
|
+
`${regExps.target.quoteStartAlt[0]}text${regExps.target.quoteEndAlt[0]}`;
|
|
188
|
+
|
|
189
|
+
// verify that corresponding quote style is present in target
|
|
190
|
+
// otherwise, construct regexps to pinpoint violation positions
|
|
191
|
+
// (for highlighting purposes)
|
|
192
|
+
let startQuote, endQuote;
|
|
193
|
+
if (sourceStyle.ascii) {
|
|
194
|
+
if (regExps.target.quotesAll.test(tar)) return;
|
|
195
|
+
startQuote = new RegExp(`(^|\\W)([${regExps.target.nonQuoteChars}'])([\\p{Letter}\\{])`, "gu");
|
|
196
|
+
endQuote = new RegExp(`([\\p{Letter}\\}])([${regExps.target.nonQuoteChars}'])(\\W|$)`, "gu");
|
|
197
|
+
} else if (sourceStyle.asciiAlt) {
|
|
198
|
+
if (regExps.target.quotesAllAlt.test(tar)) return;
|
|
199
|
+
startQuote = new RegExp(`(^|\\W)([${regExps.target.nonQuoteCharsAlt}"])([\\p{Letter}\\{])`, "gu");
|
|
200
|
+
endQuote = new RegExp(`([\\p{Letter}\\}])([${regExps.target.nonQuoteCharsAlt}"])(\\W|$)`, "gu");
|
|
201
|
+
} else if (sourceStyle.native) {
|
|
202
|
+
if (regExps.target.quotesNative.test(tar)) return;
|
|
203
|
+
startQuote = new RegExp(`(^|\\W)([${regExps.target.nonQuoteChars}'"])([\\p{Letter}\\{])`, "gu");
|
|
204
|
+
endQuote = new RegExp(`([\\p{Letter}\\}])([${regExps.target.nonQuoteChars}'"])(\\W|$)`, "gu");
|
|
205
|
+
} else if (sourceStyle.nativeAlt) {
|
|
206
|
+
if (regExps.target.quotesNativeAlt.test(tar)) return;
|
|
207
|
+
startQuote = new RegExp(`(^|\\W)([${regExps.target.nonQuoteCharsAlt}'"])([\\p{Letter}\\{])`, "gu");
|
|
208
|
+
endQuote = new RegExp(`([\\p{Letter}\\}])([${regExps.target.nonQuoteCharsAlt}'"])(\\W|$)`, "gu");
|
|
209
|
+
} else {
|
|
210
|
+
// no quotes detected in source string
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
let highlight, description, lineNumber;
|
|
215
|
+
if (startQuote.test(tar) || endQuote.test(tar)) {
|
|
216
|
+
highlight = tar;
|
|
217
|
+
if (startQuote) { highlight = highlight.replace(startQuote, "$1<e0>$2</e0>$3"); }
|
|
218
|
+
if (endQuote) { highlight = highlight.replace(endQuote, "$1<e1>$2</e1>$3"); }
|
|
219
|
+
highlight = `Target: ${highlight}`;
|
|
220
|
+
description = `Quote style for the locale ${locale} should be ${targetQuoteStyleExample}`;
|
|
221
|
+
} else {
|
|
222
|
+
highlight = `Target: ${tar}<e0></e0>`;
|
|
223
|
+
description = `Quotes are missing in the target. Quote style for the locale ${locale} should be ${targetQuoteStyleExample}`;
|
|
157
224
|
}
|
|
158
|
-
|
|
159
|
-
|
|
225
|
+
// @ts-ignore: Property 'lineNumber' does not exist on type 'Resource'
|
|
226
|
+
// there is no lineNumber property on a Resource type
|
|
227
|
+
// (preserved for compatibility)
|
|
228
|
+
if (typeof(resource.lineNumber) !== 'undefined') {lineNumber = /** @type {number} */ (resource.lineNumber); }
|
|
160
229
|
|
|
161
|
-
|
|
162
|
-
severity: this.localeOnly ? "error" : "warning",
|
|
230
|
+
return new Result({
|
|
231
|
+
/** @type {Severity} */ severity: this.localeOnly ? "error" : "warning",
|
|
163
232
|
id: resource.getKey(),
|
|
164
233
|
source: src,
|
|
165
234
|
rule: this,
|
|
166
235
|
locale,
|
|
167
|
-
pathName: file
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
} else {
|
|
173
|
-
value.highlight = `Target: ${tar}<e0></e0>`;
|
|
174
|
-
value.description = `Quotes are missing in the target. Quote style for the locale ${locale} should be ${regExps.target.quoteStart}text${regExps.target.quoteEnd}`;
|
|
175
|
-
}
|
|
176
|
-
if (typeof(resource.lineNumber) !== 'undefined') {
|
|
177
|
-
value.lineNumber = resource.lineNumber;
|
|
178
|
-
}
|
|
179
|
-
return new Result(value);
|
|
236
|
+
pathName: file,
|
|
237
|
+
highlight,
|
|
238
|
+
description,
|
|
239
|
+
lineNumber,
|
|
240
|
+
});
|
|
180
241
|
}
|
|
181
242
|
|
|
182
243
|
/**
|
|
183
244
|
* Calculate all the regular expressions we need.
|
|
184
245
|
* @private
|
|
246
|
+
* @param {string} locale
|
|
247
|
+
* @returns {RegExpCollectionForLocale}
|
|
185
248
|
*/
|
|
186
249
|
getRegExps(locale) {
|
|
187
|
-
|
|
250
|
+
// superset of all the non-ASCII start and end chars used in CLDR
|
|
251
|
+
const quoteChars = "«»‘“”„「」’‚‹›『』";
|
|
188
252
|
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
target: {}
|
|
194
|
-
};
|
|
253
|
+
// shared between all locales since there is nothing locale-specific in here
|
|
254
|
+
const quotesAscii = new RegExp(`((^|\\W)"\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?"(\\W|$))`, "gu");
|
|
255
|
+
// leave out the "s" before the final quote to take care of plural possessives (eg. my colleagues' files.)
|
|
256
|
+
const quotesAsciiAlt = new RegExp(`((^|\\W)'\\s?[\\p{Letter}\\{]|[a-rt-zA-RT-Z\\}]\\s?'(\\W|$))`, "gu");
|
|
195
257
|
|
|
196
258
|
// locale info object will tell us the quote chars for the locale
|
|
197
259
|
let li = LICache[locale];
|
|
198
|
-
|
|
199
260
|
if (!li) {
|
|
261
|
+
// @ts-ignore: An argument for 'options' was not provided
|
|
262
|
+
// LocaleInfo constructor type annotation does not reflect that options are in fact optional
|
|
200
263
|
li = new LocaleInfo(locale);
|
|
201
264
|
LICache[locale] = li;
|
|
202
265
|
}
|
|
203
266
|
|
|
204
267
|
let sourceLI = LICache[this.sourceLocale];
|
|
205
268
|
if (!sourceLI) {
|
|
269
|
+
// @ts-ignore: An argument for 'options' was not provided
|
|
270
|
+
// LocaleInfo constructor type annotation does not reflect that options are in fact optional
|
|
206
271
|
sourceLI = new LocaleInfo(this.sourceLocale);
|
|
207
272
|
LICache[this.sourceLocale] = sourceLI;
|
|
208
273
|
}
|
|
209
274
|
|
|
210
275
|
// what are all the quote chars that this locale uses?
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
276
|
+
const sourceQuoteStart = sourceLI.getDelimiterQuotationStart();
|
|
277
|
+
const sourceQuoteStartAlt = /** @type {string} */ (sourceLI.info.delimiter.alternateQuotationStart);
|
|
278
|
+
|
|
279
|
+
const sourceQuoteEnd = sourceLI.getDelimiterQuotationEnd();
|
|
280
|
+
const sourceQuoteEndAlt = /** @type {string} */ (sourceLI.info.delimiter.alternateQuotationEnd);
|
|
281
|
+
|
|
282
|
+
/** special case for Japanese: accept the main quote style only and also square brackets */
|
|
283
|
+
const targetQuoteStartChars = (locale === "ja-JP") ? ["「", "\\["] : [li.getDelimiterQuotationStart()];
|
|
284
|
+
// used in regular expressions:
|
|
285
|
+
const targetQuoteStart = targetQuoteStartChars.join("");
|
|
286
|
+
const targetQuoteStartAltChars = (locale === "ja-JP") ? ["「", "\\["] : [li.info.delimiter.alternateQuotationStart];
|
|
287
|
+
// used in regular expressions:
|
|
288
|
+
const targetQuoteStartAlt = /** @type {string} */ targetQuoteStartAltChars.join("");
|
|
289
|
+
|
|
290
|
+
/** special case for Japanese: accept the main quote style only and also square brackets */
|
|
291
|
+
const targetQuoteEndChars = (locale === "ja-JP") ? ["」", "\\]"] : [li.getDelimiterQuotationEnd()];
|
|
292
|
+
// used in regular expressions:
|
|
293
|
+
const targetQuoteEnd = targetQuoteEndChars.join("");
|
|
294
|
+
const targetQuoteEndAltChars = (locale === "ja-JP") ? ["」", "\\]"] : [li.info.delimiter.alternateQuotationEnd];
|
|
295
|
+
// used in regular expressions:
|
|
296
|
+
const targetQuoteEndAlt = /** @type {string} */ targetQuoteEndAltChars.join("");
|
|
222
297
|
|
|
223
298
|
// now calculate regular expressions for the source string that use those quotes
|
|
224
299
|
// if the source uses ASCII quotes, then the target could have ASCII or native quotes
|
|
225
|
-
|
|
226
|
-
|
|
300
|
+
const sourceQuotesNative = new RegExp(`((^|\\W)${sourceQuoteStart}\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?${sourceQuoteEnd}(\\W|$))`, "gu");
|
|
301
|
+
const sourceQuotesNativeAlt = new RegExp(`((^|\\W)${sourceQuoteStartAlt}\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?${sourceQuoteEndAlt}(\\W|$))`, "gu");
|
|
227
302
|
|
|
228
303
|
// now calculate the regular expressions for the target string that use quotes
|
|
229
304
|
// if the source contains native quotes, then the target should also have native quotes
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
new RegExp(`((^|\\W)[${
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
new RegExp(`((^|\\W)[${
|
|
238
|
-
|
|
239
|
-
// the non quote chars are used to highlight errors in the target string
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
replace(
|
|
244
|
-
replace(
|
|
245
|
-
|
|
246
|
-
replace(
|
|
247
|
-
|
|
248
|
-
replace(
|
|
249
|
-
replace(
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
305
|
+
const targetQuotesNative = new RegExp(`((^|\\W)${targetQuoteStart}\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?${targetQuoteEnd}(\\W|$))`, "gu");
|
|
306
|
+
const targetQuotesNativeAlt = new RegExp(`((^|\\W)${targetQuoteStartAlt}\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?${targetQuoteEndAlt}(\\W|$))`, "gu");
|
|
307
|
+
const targetQuotesAll = this.localeOnly ?
|
|
308
|
+
targetQuotesNative :
|
|
309
|
+
new RegExp(`((^|\\W)[${targetQuoteStart}${targetQuoteStartAlt}"]\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?[${targetQuoteEnd}${targetQuoteEndAlt}"](\\W|$))`, "gu");
|
|
310
|
+
const targetQuotesAllAlt = this.localeOnly ?
|
|
311
|
+
targetQuotesNativeAlt :
|
|
312
|
+
new RegExp(`((^|\\W)[${targetQuoteStartAlt}']\\s?[\\p{Letter}\\{]|[\\p{Letter}\\}]\\s?[${targetQuoteEndAlt}'](\\W|$))`, "gu");
|
|
313
|
+
|
|
314
|
+
// the non quote chars are used to highlight errors in the target string where they are using quotes, but
|
|
315
|
+
// they are the wrong type. Start with the superset of all quotes and then remove the valid ones so that
|
|
316
|
+
// you are left with the wrong ones for this locale.
|
|
317
|
+
const targetNonQuoteChars = quoteChars.
|
|
318
|
+
replace(sourceQuoteStart, "").
|
|
319
|
+
replace(targetQuoteStart, "").
|
|
320
|
+
replace(sourceQuoteEnd, "").
|
|
321
|
+
replace(targetQuoteEnd, "");
|
|
322
|
+
const targetNonQuoteCharsAlt = quoteChars.
|
|
323
|
+
replace(new RegExp(`[${sourceQuoteStartAlt}]`, "gu"), "").
|
|
324
|
+
replace(new RegExp(`[${targetQuoteStartAlt}]`, "gu"), "").
|
|
325
|
+
replace(new RegExp(`[${sourceQuoteEndAlt}]`, "gu"), "").
|
|
326
|
+
replace(new RegExp(`[${targetQuoteEndAlt}]`, "gu"), "");
|
|
327
|
+
|
|
328
|
+
return {
|
|
329
|
+
quotesAscii,
|
|
330
|
+
quotesAsciiAlt,
|
|
331
|
+
source: {
|
|
332
|
+
quoteStart: sourceQuoteStart,
|
|
333
|
+
quoteStartAlt: sourceQuoteStartAlt,
|
|
334
|
+
quoteEnd: sourceQuoteEnd,
|
|
335
|
+
quoteEndAlt: sourceQuoteEndAlt,
|
|
336
|
+
quotesNative: sourceQuotesNative,
|
|
337
|
+
quotesNativeAlt: sourceQuotesNativeAlt,
|
|
338
|
+
},
|
|
339
|
+
target: {
|
|
340
|
+
quoteStart: targetQuoteStart,
|
|
341
|
+
quoteStartAlt: targetQuoteStartAlt,
|
|
342
|
+
quoteEnd: targetQuoteEnd,
|
|
343
|
+
quoteEndAlt: targetQuoteEndAlt,
|
|
344
|
+
quotesNative: targetQuotesNative,
|
|
345
|
+
quotesNativeAlt: targetQuotesNativeAlt,
|
|
346
|
+
quotesAll: targetQuotesAll,
|
|
347
|
+
quotesAllAlt: targetQuotesAllAlt,
|
|
348
|
+
nonQuoteChars: targetNonQuoteChars,
|
|
349
|
+
nonQuoteCharsAlt: targetNonQuoteCharsAlt,
|
|
350
|
+
}
|
|
351
|
+
};
|
|
253
352
|
}
|
|
254
353
|
|
|
255
354
|
/**
|
|
256
355
|
* @override
|
|
356
|
+
* @param {Object} params
|
|
357
|
+
* @param {string | undefined} params.source
|
|
358
|
+
* @param {string | undefined} params.target
|
|
359
|
+
* @param {Resource} params.resource
|
|
360
|
+
* @param {string} params.file
|
|
257
361
|
*/
|
|
258
362
|
matchString({source, target, resource, file}) {
|
|
259
363
|
if (!source || !target) return; // cannot match in strings that don't exist!
|
|
260
364
|
const locale = resource.getTargetLocale();
|
|
261
|
-
|
|
262
|
-
return this.checkString(source, target, resource, file, locale
|
|
365
|
+
if (!locale) return; // nothing to do if there is no target locale specified
|
|
366
|
+
return this.checkString(source, target, resource, file, locale);
|
|
263
367
|
}
|
|
264
368
|
}
|
|
265
369
|
|
|
266
|
-
export default ResourceQuoteStyle
|
|
370
|
+
export default ResourceQuoteStyle;
|
|
371
|
+
</code></pre>
|
|
267
372
|
</article>
|
|
268
373
|
</section>
|
|
269
374
|
|
|
@@ -277,7 +382,7 @@ export default ResourceQuoteStyle;</code></pre>
|
|
|
277
382
|
<br class="clear">
|
|
278
383
|
|
|
279
384
|
<footer>
|
|
280
|
-
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.
|
|
385
|
+
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Tue Jul 09 2024 11:26:16 GMT-0700 (Pacific Daylight Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
|
|
281
386
|
</footer>
|
|
282
387
|
|
|
283
388
|
<script>prettyPrint();</script>
|