Highlighted

How to get the language of the anchoring paragraph

Advocate ,
May 11, 2019

Copy link to clipboard

Copied

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... ?

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

TOPICS
Scripting

Views

535

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to get the language of the anchoring paragraph

Advocate ,
May 11, 2019

Copy link to clipboard

Copied

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... ?

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

TOPICS
Scripting

Views

536

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
May 11, 2019 0
Advocate ,
May 11, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 11, 2019 0
K.Daube LATEST
Advocate ,
May 13, 2019

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
May 13, 2019 0