Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.mainResponder.getString

on getString (stringId, replacementTableAddress = nil, languageTableAddress = nil, pta = nil) {
	<<Looks up a string in the localization table. 4/9/00; 9:49:38 PM by Jake
		<<stringId is the dot-delimited id of the string, inside the language table's strings table
		<<replacementTableAdr is the address of a table containing name/value pairs to replace in the localized string
		<<languageTableAddress is the address of a language's lookup table.
			<<If it's nil, we get the address using mainResponder.localization.getLanguageTableAddress.
		<<Changes:
			<<05/01/00; 1:45:38 PM by JES
				<<This script is now a wrapper for the new Frontier.getString verb.
				<<Changed replacement handling to use a name/value pair table, instead of a list.
			<<03/14/01; 3:06:57 PM by PBS
				<<Optimization: look in the page table for the language table address.
			<<03/14/01; 6:38:19 PM by PBS
				<<Another optimization -- do caching when the replacementTableAddress is nil.
	
	if pta == nil {
		pta = html.getPageTableAddress ()};
	
	if languageTableAddress == nil {
		if defined (pta^.languageTableAddress) { //PBS 03/14/01: look in the page table
			languageTableAddress = pta^.languageTableAddress}
		else {
			languageTableAddress = mainResponder.localization.getLanguageTableAddress (pta: pta)}};
	local (adrLang, flCache = false);
	if replacementTableAddress == nil { //PBS 03/14/01: do caching
		flCache = true;
		local (adrCache = @temp.mainResponder.localizationCache);
		if not defined (adrCache^) {
			new (tableType, adrCache)};
		local (lang = nameOf (languageTableAddress^));
		adrLang = @adrCache^.[lang];
		if not defined (adrLang^) {
			new (tableType, adrLang)};
		if defined (adrLang^.[stringId]) {
			return (adrLang^.[stringId])}};
	
	local (s);
	if defined (config.mainResponder.globals.language) {
		s = Frontier.getString (stringId, languageTableAddress, replacementTableAddress, config.mainResponder.globals.language)}
	else {
		s = Frontier.getString (stringId, languageTableAddress, replacementTableAddress)};
	if flCache {
		adrLang^.[stringId] = s};
	
	return (s)}



This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.