Skip to main content
K.Daube
Community Expert
Community Expert
May 11, 2019
Answered

How to get the language of the anchoring paragraph

  • May 11, 2019
  • 1 reply
  • 847 views

Dear all,

To be 'really correct' in my Calendar axis function I want to write the month-names in the language of the anchoring paragraph (as long as it is de, en or fr).

  1. oFrame is the object (anchored frame) where I am in with my function
  2. oFrame.FrameParent does not point to a paragraph, but to the text frame containing the anchoring paragraph.
  3. How to find out that paragraph?

Do I need to run through all paragraphs of the text frame and check whether GetText provides andy anchors

... and then look what is anchored (fortunaely I know the ID of my frame... ?

This topic has been closed for replies.
Correct answer 4everJang

The anchored frame has a text location, which points to an object which is the  paragraph you are looking for.

oPgf = oFrame.TextLoc.obj

You should of course always check if oPgf is really a paragraph: if ( oPgf.constructor.name == "Pgf" ) as it may just be something else in one of those corner cases and throw an ugly script error, or even crash Frame.

Good luck

4everJang

1 reply

4everJang
4everJangCorrect answer
Legend
May 11, 2019

The anchored frame has a text location, which points to an object which is the  paragraph you are looking for.

oPgf = oFrame.TextLoc.obj

You should of course always check if oPgf is really a paragraph: if ( oPgf.constructor.name == "Pgf" ) as it may just be something else in one of those corner cases and throw an ugly script error, or even crash Frame.

Good luck

4everJang

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
May 13, 2019

Many thanks, Jang!

I created a function to get the default language:

function Fgr_GetDefaultLanguage (oPgf) { // === Get language from paragraph or application ========

// Arguments  oPgf  Paragraph from which to get the language

// Returns    language string "en", "de" or "fr"

// Called by  NewDiagram

// Comment    Only languages which can be handled in messages are considered

// Reference  Jang F.M. Graat in https://forums.adobe.com/message/11070209

var  langNum;

  if (oPgf.constructor.name == "Pgf") {          // assure proper object

    langNum = oPgf.Language;

  } else {

    langNum = app.Language;

  }

  switch (langNum) {

    case Constants.FV_LANG_ENGLISH          : return "en";  // x01

    case Constants.FV_LANG_BRITISH          : return "en";  // x02

    case Constants.FV_LANG_GERMAN          : return "de";  // x03

    case Constants.FV_LANG_SWISS_GERMAN    : return "de";  // x04

    case Constants.FV_LANG_FRENCH          : return "fr";  // x05

    case Constants.FV_LANG_CANADIAN_FRENCH  : return "fr";  // x06

    case Constants.FV_LANG_NEW_GERMAN      : return "de";  // x16

    case Constants.FV_LANG_NEW_SWISS_GERMAN : return "de";  // x17

    default : return "en";

  }

} //--- end Fgr_GetDefaultLanguage