bseddon / XBRL

Classes that implement the XBRL 2.1, XDT, Formulas, Generics, XFI and other XBRL specifications
GNU General Public License v3.0
41 stars 16 forks source link

Add language to `processFormulasAgainstInstances` #6

Closed tim-vandecasteele closed 5 years ago

tim-vandecasteele commented 5 years ago

Would you be open to add a language parameter to processFormulasAgainstInstances, so you can pass in the language that will be used to create the validation messages?

Currently I'm tackling this by a custom taxonomy implementation (XBRL_BE_TAX_INC) and modifying the defaultLanguage before I do the processing, but I don't know if that's the right thing to do.

bseddon commented 5 years ago

Yes, creating a custom descendant of the XBRL class is the way I has imagined users will set a language but I guess that does not work so well if you have more than one language as both cannot be default.

I am reluctant to add a parameter. Not because its a bad idea but because then all the sub functions to the point that the language argument value is used also need to be updated. This means a whole load of retesting,

Plus I don't have examples of formulas with messages in languages other than English. OK, I do now you have shown me the BE taxonomy but I don't have any corresponding instance documents I can use to exercise the formulas so I am unable to validate any changes made.

At the moment XBRL class just returns the locale string 'en-US'. So I've modified the XBRL class to expose a static property called 'specificLanguage'. The 'getDefaultLanguage' function has been modied to use this property value, if set, or otherwise return a default. Like this:

public static $specificLanguage = null;

public function getDefaultLanguage()
{
    if ( self::$specificLanguage ) return self::$specificLanguage;
    return 'en-US';
}

The property needs to be static so that all taxonomies created can share the same setting. Then it can be used like:

XBRL::$specificLanguage = 'be-FR';
$formulas->processFormulasAgainstInstances($instance);

This modification has been uploaded to the dev branch.

tim-vandecasteele commented 5 years ago

@bseddon perfect, this is more or less what I did myself.

Would you care for me crafting an example instance document for the BE taxonomy to add to the testcases?

bseddon commented 5 years ago

I'd really appreciate it if you are able to create a sample instance document to test against or even just follow along with some of your concerns. If there is a cache of instance documents submitted to the regulator, that would be OK as well.

tim-vandecasteele commented 5 years ago

I submitted one in the other issue. Sadly these documents are not disclosed, so you cannot get filled in instance documents from the regulator.