Make ExampleGenerator simpler and faster by removing ExampleType

Description

The distinction between ExampleType.ENGLISH and ExampleType.NATIVE supports a general-purpose mechanism that currently appears to support both ENGLISH and NATIVE for each ExampleGenerator, but it isn’t really used that way; there isn't such a general purpose.

In actual use in Survey Tool, there is only a single ExampleGenerator (namely SurveyMain.gTranslationHintsExample) that’s ever called with ExampleType.ENGLISH, and it’s never called with ExampleType.NATIVE. All the other ExampleGenerator objects always get called with ExampleType.NATIVE. So, we could get rid of the ExampleType argument for getExampleHtml, which could instead just look at (cldrFile == englishFile) which currently is true if and only if the type is English. This is important since it means ExampleType doesn’t need to be part of the cache key. Also, the cache never needs to be cleared for English examples given that English is read-only for Survey Tool.

The unit tests can easily be made consistent with the rule that the type is implicitly ENGLISH if and only if exampleGenerator.englishFile == exampleGenerator.cldrFile. TestCurrencyFormats needs to expect “〖€ ❬1295,00❭〗〖-€ ❬1295,00❭〗” instead of “〖USD ❬1295,00❭〗〖-USD ❬1295,00❭〗”, which is logical for locale “it”. There is no need for checkPathValue to loop through ExampleType. There is no need for ExampleType to be part of the cache key.

xpath

None

locale

None

Status

Assignee

Thomas Bishop

Reporter

Thomas Bishop

Labels

tracReporter

None

tracOwner

None

tracResolution

None

tracStatus

None

Reviewer

None

phase

None

tracCc

None

tracCreated

None

Components

Fix versions

Priority

major
Configure