Is it possible to change the decimal separator style on the fly?

Explorer ,
Feb 18, 2021

Copy link to clipboard

Copied

I've searched the forum for older posts about this topic but couldn't find anything. I may be using incorrect terms to describe my problem. (Framemaker version is the latest 2020)

 

I want to change the way decimal separators in numbers are handled in my book based on the target audience using dots or commas for them. Is there an easy way to handle this problem? For example, choosing a decimal separator style during the print out phase of a book or maybe selecting tagged numbers (if such a thing as "tagging numbers" exists) in conditional tags.

TOPICS
Formatting and numbering, Getting started, PDF output

Views

47

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi,

 

When you use structured FrameMaker, you might do this with attributes (although I do not know how).

Otherwise a translator should handle this.

Or you can change this with regular expressions.

There are numerous suggestions when you search the internet for regular expressions with decimal dot.

I would suggest this:

Search (\d+)\.(\d+)

Replace $1,$2

This replaces the dot with a comma.

Comma -> dot:

Search (\d+),(\d+)

Replace $1.$2

Explanation: \d is a digit. + means one or more. When I want to search for a . I must put a \ before it. The brackets mean that this content can be referenced in the Replace field with a $ and a number. All is explained in the FrameMaker help. And there are numerous web-sites about regular expressions. Just try it out.

This regular expression does not check for numbers like this: 1a3.456. It would still find 3.456.

And when you have similar numbers, e.g. order codes like 123.4567, then this expression will find this as well.

Therefore I recommend to really test this and to be very careful to click Change all! Always make a backup!

 

Best regards

 

Winfried

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Hi Winfried, your warning at the end is also my concern. I first need to be able to tag the numbers which are "really" numbers. Then if possible I want to be able to create different print outs from the same book for different regional target audiences.

 

I will take a look at structured document options and attributes. I'm already working in structured mode without defining any structure elements etc at the moment.

 

I was dreaming of having some regional formatting options on the pdf creation phase for this purpose.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

You could search for numbers and apply a certain character format (like "number").

Then a script could check all text with this character format and apply the regular expression.

I am a rather unexperienced ExtendScript programmer and many, many miles away from Rick Quatro, Klaus Göbel or Klaus Daube. I would assume that this would take me half a day.

Others will know, whether you could do this e.g. with XSLT.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Winfried's approach would be how I would start. Make sure you apply a character format applied to the numbers that would require this change. Then I would write an ExtendScript script to find numbers that with that character format and perform the comma/decimal swap in the appropriate direction.

 

With a structured document, I would wrap the numbers in a special element instead of directly applying a character format. Then my script would look for the element instead of the character format.

 

If the decimal or comma output only matters on XML export, then it could be done in XSLT, although I prefer to see changes like this in FrameMaker.

Likes

Translate

Translate

Report

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

Copy link to clipboard

Copied

I can think of three ways to do this, although they'd all be somewhat painful.

 

One is to create a variable for your decimal separator and just update the contents each time to match the output needed. Here your issue is that you have to insert the variable each time you type a number with decimals in it.

 

The second is to put both the period and the comma in to separate your decimals and put a conditional tag on each, then set your conditions before generating your output.

 

The third is a variation of the second, except that you'd type the same number twice, once with the period and once with the comma, and then apply the conditions to the full number instead of just the separator.

 

In the first two cases, if you're typing a lot of numbers with decimals in them in one place (such as in a table), you can insert the separators the first time, then copy and paste as you go. 

 

Note that this means using a decimal tab is going to be problematic, if not outright impossible.

 

I don't know enough about DITA to know if it's possible to use attributes to change between a period and a comma.

Likes

Translate

Translate

Report

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