[pyicu-dev] load custom resource package ... success

whit sheldon whit.sheldon at gmail.com
Mon Jul 6 06:08:26 PDT 2009


On Sun, Jul 5, 2009 at 3:00 PM, <pyicu-dev-request at osafoundation.org> wrote:

> Date: Sun, 5 Jul 2009 11:29:18 -0400
> From: whit sheldon <whit.sheldon at gmail.com>
> Subject: [pyicu-dev] load custom resource package
> To: pyicu-dev at osafoundation.org
> Message-ID:
>        <fc7ce9860907050829n6a93a90k555ae6fef42a8799 at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
>
> I am new to this list and while a -dev list seemed like it might not be the
> place for this question, I could not find a more appropriate list.  If this
> is not appropriate here, please point me in the right direction.  Thanks in
> advance for any help.
>
> I am trying to open a custom resource package with PyICU.  I have built
> PyICU against ICU 4.0 with no errors.  I have been able to successfully use
> some of the example code to access default ICU locale information and
> convert dates and times, etc.  I am now trying to access localized strings
> from a custom ICU package ( *.dat file) that I built using icu tools.  I
> know the dat file is correct because I can access it just fine using ICU
> directly from C++ code.
>
> In C++ I would use the package something like below:
>
>    typedef std::basic_string<UChar> UString;
>
>    u_setDataDirectory("path_to_data_directory");
>    UResourceBundle * m_languageResources = ures_open( "name_of_package",
> "es_MX", &err );
>    UString resString = ures_getStringByKey( m_languageResources,
> "key_to_localixed_string", &len, &err);
>
> I can see that not all of the ResourceBundle functions have been provided
> in
> the wrappers, but it appears that I should be able to load the
> ResourceBundle.  The wrapper code (see excerpt below from locale.cpp)
> appears to support the loading of a custom resource bundle that specifies a
> package but as yet I haven't figured out how get a valid ResourceBundle.
>
> excerpt from t_resourcebundle_init:   (I think this what I need where *u is
> the package name(?))
>
>
>        if (!parseArgs(args, "SP", TYPE_CLASSID(Locale),
>                       &u, &_u, &locale))
>        {
>            INT_STATUS_CALL(bundle = new ResourceBundle(*u, *locale,
> status));
>            self->object = bundle;
>            self->flags = T_OWNED;
>            break;
>        }
>
> If any one could provide some pointers I would appreciate it.  I am
> currently trying to figure out how to add to the current code to include a
> wrapper for ures_open().  Any help there would also be apreciated. :)
>


Thanks for all considerations.  I have now successfully loaded my custom
resource file.  After doing some re-reading at icu site the key  elements
were:
 1.  Set environment variable ICU_DATA to locate the file
 2.  Initialize Resource bundle as ... rb = ResourceBundle('bundle_name',
Locale('ex_MX'))

Thanks again for anyone's considerations.

Whit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osafoundation.org/pipermail/pyicu-dev/attachments/20090706/a2a77621/attachment.htm 


More information about the pyicu-dev mailing list