pdf-css-html5 transformation :Add Localized String to footer
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 47
- Joined: Thu Aug 27, 2015 9:28 pm
pdf-css-html5 transformation :Add Localized String to footer
HI,
I am looking for way to add localized strings to the footer of our pdf transformations.
In webhelp I use a localized plugin that contains our string files with our localized strings for transformations I then added to our webhelp transformation to load those variables during the html transformation.
In the pdf-css-html5 transformation it looks like you are using i18n css to change strings.
I have created a css and can control the footer using your predefined variables:
Basically I need something like string(maptitle) but instead it would be string(copyright) and be able to load the string from my localized plugin string file.
Is there a way to use my code for the webhelp transformation to add the copyright in the footer of of the pdf transformation?
Or do I need to use the i18n css
In which case can I create i18n css files in my own template css folder and add just the strings we need to customize?
Thanks
Arron Varga
I am looking for way to add localized strings to the footer of our pdf transformations.
In webhelp I use a localized plugin that contains our string files with our localized strings for transformations I then added to our webhelp transformation to load those variables during the html transformation.
In the pdf-css-html5 transformation it looks like you are using i18n css to change strings.
I have created a css and can control the footer using your predefined variables:
Code: Select all
@page :right {
@top-left{
content:" ";
}
@top-right{
content:" ";
}
@bottom-left {
content: string(maptitle);
border-top: 2px solid grey;
vertical-align: top;
padding-top:10px;
}
@bottom-right {
content: counter(page);
border-top: 2px solid grey;
vertical-align: top;
padding-top:10px;
}
@bottom-center{
content:" ";
border-top: 2px solid grey;
vertical-align: top;
}
}
Is there a way to use my code for the webhelp transformation to add the copyright in the footer of of the pdf transformation?
Or do I need to use the i18n css
Code: Select all
/
* Custom string */
*[class ~= "map/map"]:lang(en) {
string-set: footer-copyright "Copy right footer text";
}
Thanks
Arron Varga
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Post by julien_lacour »
Hello Arron,
At the moment for adding localized strings into the pdf-css-html5 transformation you may use i18n css files.
In your case it will look like this:
Make sure to keep the 'toc-header' key because if you do not set it here, your custom rule will overwrite the default one and this string-set will not appear translated.
Note: If you are missing some of the translations for 'toc-header' the original files are in Oxygen installation directory (in frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.pdf.css/css/print/i18n - just take the languages you need)
Regards,
Julien
At the moment for adding localized strings into the pdf-css-html5 transformation you may use i18n css files.
In your case it will look like this:
Code: Select all
*[class ~= "map/map"] {
string-set: toc-header "Contents", footer-copyright "Copy right footer text";
}
Note: If you are missing some of the translations for 'toc-header' the original files are in Oxygen installation directory (in frameworks/dita/DITA-OT3.x/plugins/com.oxygenxml.pdf.css/css/print/i18n - just take the languages you need)
Regards,
Julien
-
- Posts: 47
- Joined: Thu Aug 27, 2015 9:28 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Great thanks.
I got the localized content to display using the i18n css sheets.
Next issue is we use a different copyright footer text or add text based on the maps status which we put in the map's <topicmeta>
I have looked at the oxy_xpath and tried to get it to work.
However it does not appear you can use the oxy_xpath in a string-set?
In the webhelp, using xsl it was very easy to change the string footer based on the test of name="status" content="draft" and apply a different footer based on the value found in the @content attribute.
I can not find a sample of code that I can get to work where I can use xpath to get the value of othermeta status @content attribute and based on the value change the string-set.
I got the localized content to display using the i18n css sheets.
Code: Select all
string-set: footer-copyright "copy right text";
Code: Select all
<othermeta class="- topic/othermeta " name="status" content="draft"/>
However it does not appear you can use the oxy_xpath in a string-set?
In the webhelp, using xsl it was very easy to change the string footer based on the test of name="status" content="draft" and apply a different footer based on the value found in the @content attribute.
I can not find a sample of code that I can get to work where I can use xpath to get the value of othermeta status @content attribute and based on the value change the string-set.
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Post by julien_lacour »
Hello,
You should be able to use oxy_xpath in your string-set.
On my side I tried
First I used a simple ditamap with the following content:
Then I use the following selectors in my CSS:
In my PDF the word "draft" appears in the bottom-center margin of each page.
Make sure you do not have multiple match on your XPath (the function does not return anything if the XPath is not OK).
You can test your XPath using the .merged.xml file and Oxygen's XPath Builder.
Regards,
Julien
You should be able to use oxy_xpath in your string-set.
On my side I tried
First I used a simple ditamap with the following content:
Code: Select all
map>
<title>Test</title>
<topicmeta>
<othermeta name="status" content="draft"/>
</topicmeta>
Code: Select all
@page {
@bottom-center {
content: string(footer-copyright);
}
}
*[class ~= "map/map"] {
string-set: toc-header "Contents", footer-copyright oxy_xpath('//*[contains(@class, "topic/othermeta")]/@content');
}
Make sure you do not have multiple match on your XPath (the function does not return anything if the XPath is not OK).
You can test your XPath using the .merged.xml file and Oxygen's XPath Builder.
Regards,
Julien
-
- Posts: 47
- Joined: Thu Aug 27, 2015 9:28 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Hi thanks. I will try the code out.
However that was not exactly what I was hoping to do.
What I wanted to do was set the footer copyright string based on what status is set to:
If @status = "draft" then footer-copyright = "Draft copyright text"
Else If @status = "released" then footer-copyright = "Released copyright text"
Else If @status = "published" then footer-copyright = "Published copyright text"
However that was not exactly what I was hoping to do.
What I wanted to do was set the footer copyright string based on what status is set to:
If @status = "draft" then footer-copyright = "Draft copyright text"
Else If @status = "released" then footer-copyright = "Released copyright text"
Else If @status = "published" then footer-copyright = "Published copyright text"
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Post by julien_lacour »
Hello,
In this case you need to use nested conditions like this
Feel free to change the displayed text, if nothing appears make sure you XPath is correct using the XPath Builder view.
Regards,
Julien
In this case you need to use nested conditions like this
Code: Select all
@page {
@bottom-center {
content: string(footer-copyright);
}
}
*[class ~= "map/map"] {
string-set: toc-header "Contents", footer-copyright oxy_xpath('if (//*[contains(@class, "topic/othermeta")]/@content = "draft") then "Draft" else if (//*[contains(@class, "topic/othermeta")]/@content = "released") then "Released" else if (//*[contains(@class, "topic/othermeta")]/@content = "published") then "Published" else ""') " copyright text";
}
Regards,
Julien
-
- Posts: 47
- Joined: Thu Aug 27, 2015 9:28 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Thanks that worked perfectly.
Sorry last question as I need to do this for 20 languages is there an easy method to include a group of files to the pdf output?
In webhelp I could load the entire folder using fileset element:
It does not look like I can use <fileset> in the pdf opt resource section.
Would the best way be to create a i18n css file that imports all the i18n css files for all the languages?
Sorry last question as I need to do this for 20 languages is there an easy method to include a group of files to the pdf output?
In webhelp I could load the entire folder using fileset element:
Code: Select all
<fileset>
<include name="js/*.js"/>
<include name="css/*.css"/>
<include name="resources/**/*"/>
<exclude name="resources/**/*.svn"/>
<exclude name="resources/**/*.git"/>
</fileset>
Would the best way be to create a i18n css file that imports all the i18n css files for all the languages?
-
- Posts: 665
- Joined: Wed Oct 16, 2019 3:47 pm
Re: pdf-css-html5 transformation :Add Localized String to footer
Post by julien_lacour »
Hello,
Indeed, you can use the fileset element inside your publication template like in this example
But I do not think this is what you want in this case.
The best way to integrate all these files is, as you mentioned, to create a main CSS style sheet and import all the languages
For example let's take the main file 'custom-i18n.css', it will contains:
Each of these imported files containing the translation for one language.
Then you just need to import the main file everytime you need to use these i18n translations.
Regards,
Julien
Indeed, you can use the fileset element inside your publication template like in this example
Code: Select all
<resources>
...
<fileset>
<include name="js/*.js"/>
<include name="css/*.css"/>
...
</fileset>
</resources>
The best way to integrate all these files is, as you mentioned, to create a main CSS style sheet and import all the languages
For example let's take the main file 'custom-i18n.css', it will contains:
Code: Select all
@import 'custom-i18n-en.css';
@import 'custom-i18n-fr.css';
@import 'custom-i18n-de.css';
...
Then you just need to import the main file everytime you need to use these i18n translations.
Regards,
Julien
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service