Create right-to-left paragraph style, based on existing (left-to-right) style
When working with Arabic translations, my current layout process involves defining all paragraph styles for the document in the English layout (let's use "H1" as an example). Then I create a new paragraph style called "H1_RTL," based on H1, alignment = right, paragraph composer = Adobe World-Ready Paragraph Composer.
The closest I've been able to come is modifying the CreateCharacterStyle sample script to create a new paragraph style using the selected text; this sets "Based on" to "[none]" and copies the other parameters--that's fine, it seems like it would be easier to have the script grab the "Based on" property instead but I could be wrong--but even using that, I can only create an exact copy of the selected style. I've got no idea how to change the alignment or the composer.
I've found a way to add a dialog box to set the name for the new style into the CreateCharacterStyle.jsx script that comes packaged with InDesign, and changed "character" to "paragraph" throughout the rest of the script, and if that's the only change I make, it works just fine. However, trying to add myParagraphStyle.composer = "Adobe World-Ready Paragraph Composer" throws an error, and I'm not sure what other expressions to try for that.
I've also tried every single parameter I can find any reference to that might change the paragraph alignment (alignment, justification, position, paragraphAttributes.justification, characterAttributes.justification), with various permutions of possible values, and none of them have worked.
Here's the dialog box, plus the first few parameters the script grabs from the selected text:
function myDefineParagraphStyle(myParagraphStyleName){
var myParagraphStyle;
var myDocument = app.activeDocument;
//Create the character style if it does not already exist.
myParagraphStyle = myDocument.paragraphStyles.item(myParagraphStyleName);
try{
myParagraphStyle.name;
}
catch (myError){
myParagraphStyle = myDocument.paragraphStyles.add({name:myParagraphStyleName});
}
var mySourceText;
/* check if the text cursor is inside some text first */
if (app.selection.length == 1 && app.selection[0].hasOwnProperty("baseline"))
mySourceText = app.activeDocument.selection[0].appliedParagraphStyle;
else
mySourceText = app.activeDocument.textDefaults.appliedParagraphStyle;
/* clear out any possible previous Find text and formatting */
app.findTextPreferences = null;
myParagraphStyle.appliedFont = mySourceText.appliedFont;
myParagraphStyle.fontStyle = mySourceText.fontStyle;
myParagraphStyle.pointSize = mySourceText.pointSize;
/*the list of parameters continues on in this way for some time*/