Norway


Booleans. One would think that simple true and false would be sufficient to represent all the possible values. However, even more than dates, they are one of the most difficult things to master in all of computer science. There are all manner of possible values and many different ways of comparing different entities.

Compounding everything is another dimension to boolean-ness: . After all, not every language uses English spellings of true and false. In high school, they made me take French, so it’d be vrai and faux. For most of us, we’d put the language-specific spelling in an application-phrases file, cache it and pick the appropriate spelling based upon the meaning of the required phrase. However, the underlying core values of /falsehood would still be programming-language-specific.

For most of us…

  class Internationalization {
     // These will index into the list of language-specific phrases
     public enum Phrases { TRUE,
                           FALSE,
                           ...
     };
 
     private List<String> languageSpecificPhrases = new ArrayList<>();
	 
     public  Internationalization() {
       // Load strings from configured language file into: languageSpecificPhrases...
     }

     public String getPhrase(Phrases phrase) {
       return languageSpecificPhrases.get(phrase.ordinal()).
     }	   

     public boolean getLanguageSpecificBooleanValueForTrue() {
       return true;
     }

     public boolean getLanguageSpecificBooleanValueForFalse() {
       return !getLanguageSpecificBooleanValueForTrue();
     }

  }
- otter icon - The Truth About Internationalization &#8211; The Daily WTF [Advertisement]
Continuously monitor your servers for configuration changes, and report when there’s configuration drift. Get started with Otter today!



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here