The NLS Enabler is a tool for assisting the NLS enablement of an application.Open the NLS Enabler by selecting the Transcript menu item Tools->NLS Tool->Enable Application. A prompter will open with toggle buttons for selecting the types of warnings to be flagged, a list widget to select the application(s) to check, and a toggle button associated with the String Literals warnings to indicate whether or not strings previously marked as ‘ignored’ (comment of $NON-NLS$) should continue to be ignored or should be reanalyzed . Select one or more of the applications and one or more of the types of warnings and hit OK.Identify direct references to potentially problematic Classes. These classes are in the class variable WarningClasses of the NlsClassWarning class. The default warning classes are String and DBString.Identify direct references to potentially problematic concatenation selectors. These selectors are in the class instance variable warningSelectors of the NLSConcatenationWarning class. The default warning selector is #,.Identify direct references to potentially problematic stream-oriented selectors. These selectors are in the class instance variable warningSelectors of the NlsStreamSelectorWarning class. The default warning selectors are #nextPut:, #nextPutAll:, and #next:put:.Identify direct references to potentially problematic general selectors. These selectors are in the class instance variable warningSelectors of the NlsGeneralSelectorWarning class. The default warning selectors are #asCharacter, #asString, #asDBString, and #printString.Identify direct references to String literals. String warnings may be replaced by message references using the NLS Enablement Browser.The NLS Enablement Browser has the following layout:| 3 || 6 || 7 |The NLS Enablement Browser is used for viewing warnings and NLS enabling methods. Only methods flagged by the selected warnings are displayed. The browser has seven main areas:
3. The list of the methods with warnings found by the NLS Enabler.To externalize the strings in an application the NLS Enabler is opened with String Literal warnings enabled. Strings flagged by String Literal warnings can be replaced by named or indexed messages. A named message is a message that stays resident in the image whereas an indexed message is loaded on demand. A message should be kept resident if it is used frequently, otherwise it should be load on demand to keep the size of the image to a minimum.
1. Replace strings built using the #, selector. Replace with bindWith:. This will require someone to check code and replace the references manually.
2. Externalize the strings using the NLS Enabler.
3. Open the NLS Enabler again, select the class warning check and check the generated warnings for the application.
4. Open the NLS Enabler again, select all checks and check the generated warnings for the application.Externalized strings are referenced using an EsPoolDictionary (a pool) and an NlsMessageCatalog (a catalog, not referenced in the method source). The catalog maintains an external file that has the resident and indexed messages for a catalog. A pool dictionary holds onto the catalog and its resident messages in the image and can be used to access the indexed messages in the catalog. A method refers to the pool to get the indexed and resident messages.When enabling an application the pool and catalog to be used must be specified. If the user attempts to replace a string with a pool reference without setting the pool first, the Pool Definition prompter is opened. The Pool Definition prompter can also be opened using the Checking->Change Default Pool ... menu option.The Pool Definition prompter has 5 fields to be entered:
1. A combo box that gives the user the choice of the working directory or one of the directories in Locale nlsPath.
4.
5.
1.
2. Code that is executed after an application is removed. The #wasRemovedCode: removes the catalogs created from the Smalltalk dictionary when executed. If the #wasRemovedCode: already exists, the required #wasRemovedCode: is added to the existing code if the required code is not currently in it.If the catalog does not have its compatabilities set, the user will be asked if they wish to set default compatabilities. Compatabilities are arrays used to define compatible locales. The default is #((english us ansi-ascii) (* * *)) which indicates that all locales are compatible with the english us ansi-ascii locale. The compatabilities for a catalog can be set using the Catalog File Editor. See the NLS Programmers Reference for additional information on compatabilities.If a string is not selected the menu options will be grayed out. If the pool or catalog to be used is not set the pool selection browser will be opened first. If the pool and catalog values are entered the replacement can proceed. If a string is in a literal array the replacement will not be allowed. This is to prevent the accidental bugs that can occur by replacement. For example the array #('aa' 'bb' 'cc') would be replaced by something of the form #(Mx1 Mx2 Mx3) which would return #Mx1 #Mx2 #Mx3 rather than 'aa' 'bb' 'cc'.Replace by a named message (load resident). If the prefix is set the name suggested will be the next resident message name based on the prefix and a counter stored in the catalog file or an existing key if the same string had been previously externalized using the selected catalog. Otherwise an empty prompter will be shown. The entered value (if it is not empty) will replace the literal string in the text of the method and the literal string will be used as a comment that will be appended at the end of the line. For instance the literal string 'Literal String' would have "$NLS$ Literal String $NLS$" appended at the end of the line when replaced by a message reference.Replace by an indexed message (load on demand). The user will be prompted with the next available index in the catalog or the index of the string if it already in the catalog, but this value can be changed by the user. The entered value (if it is not empty) will be used to build a message reference (e.g. NlsCatKRN indexedMsg: 7) to replace the literal string in the text of the method and the literal string will be used to make a comment that will be appended at the end of the line in the same manner as Replace With Name.Append a comment at the end of the line indicating that the string is to be ignored by the tool if the methods are generated again, either by opening another NLS Enabler on the application or by regenerating the methods using the Method ->Update menu option. If all of the literal strings left in a method are marked as ignored the method will not be flagged next time the warnings are generated.If a method is in an extension of a class in an application, references to named messages must be indirect (i.e. NlsCatCFS residentMsg: 'Joe') since the pool cannot be added to the class definition in an application where a class is extended. If Warn For Indirect is enabled then the user is warned before an indirect replacement begins, otherwise it is done without warning.The default warning types are Class, Selector, String and Character warnings. To add a warning, a subclass of NlsWarning must be created. An NlsWarning has a position (a Point - start and finish position in the text) and a warning (an Object). They must be set when the warning is created. They are used by the browser to highlight the warning and to show the description of the warning. Any scheme may be used to determine the existence and positions of warnings. The existing warnings are found using the parse tree of the method. The API required to use them is described later.
6.
7. Rather than overriding some or all of the above mentioned methods the check can be done by using a parse tree node (EsParseNode subclass). If this is done, none of the NlsWarning methods need be overwritten but some or all the following methods in EsParseNode will have to be overridden by the EsParseNode to be used for the check.
|