UIZE JavaScript Framework

MODULES Uize.Build.AuditStrings

1. Introduction

The Uize.Build.AuditStrings package provides a method to audit all JavaScript files in a folder for literal strings - useful for internationalization.

DEVELOPERS: Chris van Rensburg

This build script recurses through all folders of a project, harvests all the string literals from JavaScript files, filters them into different buckets depending on their likelihood of internationalizability, and produces a report with summaries for all the JavaScript files.

The build script groups the literal strings it finds inside a JavaScript file into four buckets...

1.1. NON-INTERNATIONALIZABLE STRINGS

This category includes strings that are recognized by certain patterns as being non-internationalizable strings, including...

DOM event names (e.g. click)
very JavaScript specific keywords (e.g. function)
HTML specific attribute names (e.g. href)
sufficiently distinctive HTML tag names (e.g. div), file extensions (e.g. .gif)
strings that are only whitespace
strings that have no letter characters
hex formatted RGB color values (e.g. #ff0000)
module names (e.g. Uize.Widget.Bar)
any string starting with "Uize"
underscore delimited identifiers (e.g. button_big_disabled)
Changed.[propertyName] events (e.g. Changed.value), and the Changed.* event
sufficiently distinguishable URL paths (e.g. myfolder/mysubfolder/myfile.html)
camelCase identifiers (e.g. languageSortAscending)

1.2. LIKELY NON-INTERNATIONALIZABLE STRINGS

This category includes strings with only one letter character (e.g. a), and strings that look like short url snippets (e.g. myfolder/mysubfolder).

1.3. POSSIBLY INTERNATIONALIZABLE STRINGS

This category includes strings that are not filtered out into either the NON-INTERNATIONALIZABLE STRINGS, LIKELY NON-INTERNATIONALIZABLE STRINGS, or LIKELY INTERNATIONALIZABLE STRINGS categories.

1.4. LIKELY INTERNATIONALIZABLE STRINGS

This category includes strings that are not filtered out into either the NON-INTERNATIONALIZABLE STRINGS or LIKELY NON-INTERNATIONALIZABLE STRINGS categories and that contain three adjacent, space separated words, where the middle word is all lowecase.

Below is a snippet from the log file after this build script was run inside the UIZE-JavaScript-Framework folder of the UIZE Web site project...

LOG FILE SNIPPET

***** C:\~uize\UIZE-JavaScript-Framework\site-source\js\Uize.Widget.TableSort.js
  TARGET FILE: C:\~uize\UIZE-JavaScript-Framework\site-source\js\Uize.Widget.TableSort.js
  BUILT (ALWAYS BUILD), BUILD DURATION: 188ms
    NON-INTERNATIONALIZABLE STRINGS
       --- 92,101,189
      TD --- 54
      TR --- 142,249,274
      Uize.Dom.Basics --- 22
      Uize.Widget.TableSort --- 21
      headingLitClass --- 346
      headingOverClass --- 342
      languageSortAscending --- 350
      languageSortDescending --- 355
      click --- 292
      rowOverClass --- 360
      updateUi --- 339

    LIKELY NON-INTERNATIONALIZABLE STRINGS

    POSSIBLY INTERNATIONALIZABLE STRINGS
      TH --- 55
      tbody --- 50
      thead --- 272

    LIKELY INTERNATIONALIZABLE STRINGS
      Click to sort in ascending order --- 352
      Click to sort in descending order --- 357

A few things to notice about the format...

the strings are listed in ASCIIbetically sorted order
to the right of each string is a listing of all the line numbers on which the string occurs

THIS ONE'S SLOW

Be warned: this build script can be quite slow to run, especially if you have a large project with many folders and many JavaScript files. It could take a few minutes to process all JavaScript files in a large project. You'll know when it's done running by the modified date of the associated log file, or you can watch the WSCRIPT.EXE process in the Windows Task Manager.

NOTES

the summary info for this build script is output to the log file Uize.Build.AuditStrings.log

1.5. Examples

There are no dedicated showcase example pages for the Uize.Build.AuditStrings module.

SEARCH FOR EXAMPLES

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

SEARCH

1.6. Implementation Info

The Uize.Build.AuditStrings module defines the Uize.Build.AuditStrings package under the Uize.Build namespace.

1.6.1. Features Introduced in This Module

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

STATIC METHODS

Uize.Build.AuditStrings.perform

STATIC PROPERTIES

Uize.Build.AuditStrings.moduleName | Uize.Build.AuditStrings.pathToResources

1.6.2. Features Overridden in This Module

No features have been overridden in this module.

1.6.3. Features Inherited From Other Modules

This module has no inherited features.

1.6.4. Modules Directly Under This Namespace

There are no modules directly under this namespace.

1.6.5. Unit Tests

There is no dedicated unit tests module for the Uize.Build.AuditStrings module.

2. Static Methods

2.1. Uize.Build.AuditStrings.perform

IMPLEMENTATION INFO

this feature was introduced in this module

3. Static Properties

3.1. Uize.Build.AuditStrings.moduleName

IMPLEMENTATION INFO

this feature was introduced in this module

3.2. Uize.Build.AuditStrings.pathToResources

IMPLEMENTATION INFO

this feature was introduced in this module