Get active language rendition programmatically

  1. 8 months ago

    Hello
    Is it possible to determine the language rendition that an XPUB is using programatically? For example, if I have an XPUB file with an English and Spanish rendition, and the user chooses Spanish but their browser locale is en-US, how can I tell that they have loaded Spanish instead of English.

    I have a Javascript file which I would like to have different actions depending on the language they chose. I know I can do a modification in each rendition, but that creates a maintenance problem as for each language we would have to make any changes in every rendition version.

    Is there a Pubcoder Javascript call that would indicate what language is loaded?

    Thank you

  2. Angelo S

    15 Mar 2024 Administrator

    Hello Craig,
    you should be able to access rendition information using xreaderjs.rendition but beware that this (and actually anything inside xreader and xreaderjs objects) is internal code which could change in the future, breaking your code.

  3. Deleted 8 months ago by Agness A
  4. Deleted 8 months ago by Angelo S
  5. Thank you Angelo. I didn't have much luck accessing the xreaderjs object or xreaderjs.rendition. I could read things from xreader though. But I agree it is best not to use undocumented functions.

    Do you think it would be possible to add a feature to the public PubCoder API to read the rendition being used?

    It seems like it may be useful in some applications to know the rendition (screen size, language and orientation) that is being used.

  6. Angelo S

    18 Mar 2024 Administrator
    Edited 8 months ago by Angelo S

    Hello Craig,
    you should have access to it when exporting the project, you don't have access to it in the quick preview, since it is a feature of the xreaderjs web reader, and the quick preview does not use the web reader.
    Any way, the public js apis are in the pubcoder object but we cannot include info about renditions there, because the pubcoder object only includes functions and data shared by features available in every format using js, but not every format supports renditions in pubcoder (e.g. EPUB does not).

    What we could do is including info about the current language, for example in pubcoder.project.language, but frankly that's not in our roadmap at the moment.

    Another approach that you can take is using different project titles for the different renditions, get the current title using pubcoder.project.title and use that value to understand what language is active.

  7. Hi Angelo. Using pubcoder.project.title is a great idea. We will do that and use a different title in each rendition. That will work for this application.
    Thank you

  8. 7 months ago
    Deleted 7 months ago by Angelo S
 

or Sign Up to reply!