Language Dependent strings

Mike Bray (Quote Loader Author)'s Avatar

Mike Bray (Quote Loader Author)

30 May, 2018 02:15 PM

Is there a safe way to get the value of a language dependent string? For example Account.get.SecuritySubType returns a string which comes from the dictionaries, i.e. "mutualSubType_etf" = "Exchange Traded Fund", which will change with language. If I wish to know the difference between the Mutual Funds type subtypes ETFs and Money Market Funds how can I test for this without hardcoding the English into the extension?

Is there a list of constants available to interrogate language dependent strings?

  1. Support Staff 1 Posted by Sean Reilly on 31 May, 2018 10:35 AM

    Sean Reilly's Avatar

    Hi Mike,

    Great question! It looks like the security subtypes are all stored as already-localised strings, since we thought customers would want to add or edit their subtype names.

    The default subtypes from from the com.moneydance.apps.md.controller.SecuritySubtypeManager class which includes the following method. You can get the resource IDs from the code or feel free to copy the whole thing:

     private List<String> getDefaultSubtypes(SecurityType securityType, MDResourceProvider resources) {
        switch (securityType) {
          case MUTUAL:
            return Arrays.asList(resources.getStr("mutualSubType_US"),
                                 resources.getStr("mutualSubType_intl"),
                                 resources.getStr("mutualSubType_bond"),
                                 resources.getStr("mutualSubType_balanced"),
                                 resources.getStr("mutualSubType_money"),
                                 resources.getStr("mutualSubType_etf"));
          case BOND:
            return Arrays.asList(resources.getStr("bondSubType_corp"),
                                 resources.getStr("bondSubType_muni"),
                                 resources.getStr("bondSubType_revenue"),
                                 resources.getStr("bondSubType_junk"));
          case OPTION:
            return Arrays.asList(resources.getStr("optionSubType_nonqual"),
                                 resources.getStr("optionSubType_incentive"));
          case OTHER:
            return Arrays.asList(resources.getStr("otherSubType_realestate"),
                                 resources.getStr("otherSubType_gold"),
                                 resources.getStr("otherSubType_oil"));
          case CD:
            return Arrays.asList(resources.getStr("cdSubType_fixed"),
                                 resources.getStr("cdSubType_variable"),
                                 resources.getStr("cdSubType_callable"),
                                 resources.getStr("cdSubType_liquid"),
                                 resources.getStr("cdSubType_bumpup"),
                                 resources.getStr("cdSubType_broker"),
                                 resources.getStr("cdSubType_zerocoupon"));
          case STOCK:
          default:
            return Arrays.asList(resources.getStr("stockSubType_largecap"),
                                 resources.getStr("stockSubType_midcap"),
                                 resources.getStr("stockSubType_smallcap"),
                                 resources.getStr("stockSubType_growth"),
                                 resources.getStr("stockSubType_value"));
        }
      }
    

    Thanks!

    Sean Reilly
    Developer, The Infinite Kind
    http://infinitekind.com

  2. 2 Posted by Mike Bray (Quot... on 31 May, 2018 11:27 AM

    Mike Bray (Quote Loader Author)'s Avatar

    Thanks Sean

    I was looking at it but could not get a link to 'resources' which I
    assume is set up within the product. How do I get this?
    Regards
    Mike

  3. 3 Posted by Mike Bray (Quot... on 31 May, 2018 12:56 PM

    Mike Bray (Quote Loader Author)'s Avatar

    Hi Sean

    I think I have cracked it. I have created a utility class that implements MDResourceProvider when created does:

        objUserPref = UserPreferences.getInstance();
        objResources = objUserPref.getResources();
    

    The getstr("mutualSubType_etf") then does

    public String getStr(String strKey) {
        return objResources.getString(strKey);
    }
    

    and returns the string I want. It even comes out in French if the locale is French.
    Mike

  4. Mike Bray (Quote Loader Author) closed this discussion on 13 Jun, 2018 12:01 PM.

  5. Mike Bray (Quote Loader Author) re-opened this discussion on 22 Jul, 2018 04:48 AM

  6. Mike Bray (Quote Loader Author) closed this discussion on 22 Jul, 2018 04:48 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

02 Dec, 2024 01:34 PM
02 Dec, 2024 12:49 PM
02 Dec, 2024 11:29 AM
02 Dec, 2024 08:29 AM
02 Dec, 2024 07:08 AM