• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to get the language of the anchoring paragraph

Community Expert ,
May 11, 2019 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... ?

TOPICS
Scripting

Views

701

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
community guidelines

correct answers 1 Correct answer

Advocate , May 11, 2019 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

Votes

Translate

Translate
Advocate ,
May 11, 2019 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

Votes

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
community guidelines
Community Expert ,
May 13, 2019 May 13, 2019

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines