project BLF > class Cacher > method GetCacherTranslation
Description
Lookup a translatable string in the fcTranslation table
Parameters
iiStringNumber | input | integer | identification of the translation to lookup |
icProjectShortCode | input | character | identification of the translation to lookup |
bcStringText | input-output | character | the translation itself |
Internal usage
BLF
program code (program1/cacher.p)
define buffer bfcTranslation for fcTranslation.
if current-language = ?
or current-language = "?"
then vcCurrentLanguage = "".
else vcCurrentLanguage = current-language.
if vcCurrentLanguage = ""
then return.
find first translationsCache where
translationsCache.tcLanguage = vcCurrentLanguage and
translationsCache.tcProjectCode = icProjectShortCode and
translationsCache.tiStringNumber = iiStringNumber no-error.
if not available translationsCache
then for each bfcTranslation no-lock where
bfcTranslation.TranslationLanguageCode = vcCurrentLanguage and
bfcTranslation.TranslationProjShortCode = icProjectShortCode and
bfcTranslation.TranslationStringNumber = iiStringNumber on error undo, throw:
create translationsCache.
assign translationsCache.tcLanguage = vcCurrentLanguage
translationsCache.tcProjectCode = icProjectShortCode
translationsCache.tcStringText = bfcTranslation.TranslationStringText
translationsCache.tiStringNumber = iiStringNumber.
assign viTranslationsCacheCount = viTranslationsCacheCount + 1.
leave.
end. /* if not available translationsCache */
if not available translationsCache
then do:
create translationsCache.
assign translationsCache.tcLanguage = vcCurrentLanguage
translationsCache.tcProjectCode = icProjectShortCode
translationsCache.tcStringText = ""
translationsCache.tiStringNumber = iiStringNumber.
assign viTranslationsCacheCount = viTranslationsCacheCount + 1.
end. /* if not available translationsCache */
/*
* Recently used translations get a higher sequence.
* Use int64 as number of translations could get very big on long running appserver processes.
*/
vgTranslationsCacheNR = vgTranslationsCacheNR + 1.
translationsCache.tgSequence = vgTranslationsCacheNR.
if translationsCache.tcStringText <> ""
then bcStringText = translationsCache.tcStringText.
release translationsCache.
/* ================================================================= */
/* Clean up the translation cache. Clear 1000 records at a time */
/* so the cleanup does not occur too often. */
/* ================================================================= */
if viTranslationsCacheCount > viTranslationsCacheLimit
then for each translationsCache by translationsCache.tgSequence on error undo, throw:
delete translationsCache.
viCleanup = viCleanup + 1.
if viCleanup > 999
then leave.
end.
viTranslationsCacheCount = viTranslationsCacheCount - viCleanup.