Translating javascript within html files, Studio 2014
Thread poster: ajitrans
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
May 25, 2014

I recently upgraded to Studio 2014 from 2011 because I saw that there is a "Parser" function that presumably allows one to make certain strings translatable from within embedded scripts, etc.

I have HTML files that contain embedded JavaScripts. The scripts contain translatable text but only some of it should be translated. When processing files in Studio 2011, you can tell it to either exclude all strings in scripts or include all strings in scripts ( File Types > HTML > Scripts > A
... See more
I recently upgraded to Studio 2014 from 2011 because I saw that there is a "Parser" function that presumably allows one to make certain strings translatable from within embedded scripts, etc.

I have HTML files that contain embedded JavaScripts. The scripts contain translatable text but only some of it should be translated. When processing files in Studio 2011, you can tell it to either exclude all strings in scripts or include all strings in scripts ( File Types > HTML > Scripts > Allow translation of all strings OR Do not allow translation of any strings in scripts). But what I need is to have it parse all scripts and look for certain markers to indicate which strings should be translated and which shouldn't.

I purchased 2014 so that I could configure rules that would tell Studio which strings were translatable and which were not. But it seems that now I can't get 2014 to recognize ANY javascript strings, even with the default settings. No matter what I do in the File Types > HTML 5 settings, Studio does not recognize ANY strings within tags.

Does anyone have any idea how to
1) Get Studio 2014 to treat text within script tags as translatable and/or;
2) Create rules to tell Studio which embedded javascript strings are translatable and which are not?

Specifically, for number two above, I'd like to create a rule that says all text that appears in p tags within a script tag is translatable.

Any ideas? Thank you!

David Nevins
Collapse


 
rathoreharpreet
rathoreharpreet
India
English to Punjabi
+ ...
Try another software May 26, 2014

Try to use notepad++

 
RWS Community
RWS Community
United Kingdom
Local time: 10:43
English
The feature you refer to... May 26, 2014

... relates to handling embedded content in XML files. You could always do this in Studio using embedded content rules written using regex. But now you can select an html filter, or some other filter, to do the processing of the embedded content and you don't have to write the regex rules.

But this is only currently from XML files. A future release is expected to extend this capability, but for now you cannot handle scripts in html files via an embedded content filter.

... See more
... relates to handling embedded content in XML files. You could always do this in Studio using embedded content rules written using regex. But now you can select an html filter, or some other filter, to do the processing of the embedded content and you don't have to write the regex rules.

But this is only currently from XML files. A future release is expected to extend this capability, but for now you cannot handle scripts in html files via an embedded content filter.

Perhaps, depending on the content of the file in general you can handle this a different way? If the html file contains only script content, then it might be worth creating an XML filetype for this and then use the html filtetype inside that to handle the content of the script. But this would depend on the content of the file.

If you are allowed to share it I can take a look and perhaps suggest something to help?

Regards

Paul
Collapse


 
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
TOPIC STARTER
Thank you! Here's a sample... May 26, 2014

Thank you Paul and rathoreharpreet,

I spent a long time experimenting with different methods to get 2014 to recognize the script content, so it's good to know now that it's not even possible at this point. (Well, not "good", but at least I can take a break

If Studio 2014 now no longer recognizes ANY script content (let alone have the ability to parse it), why does the script tag appear in the Parser area o
... See more
Thank you Paul and rathoreharpreet,

I spent a long time experimenting with different methods to get 2014 to recognize the script content, so it's good to know now that it's not even possible at this point. (Well, not "good", but at least I can take a break

If Studio 2014 now no longer recognizes ANY script content (let alone have the ability to parse it), why does the script tag appear in the Parser area of the HTML 5 File Type in Project Settings? There you can configure properties for that tag, specifically the Translate property (as you can do with a bunch of other html tags,) but changing these properties of the script tag seems to have no effect. None of the script content shows up as translatable. It did in Studio 2011 (but of course in 2011, there was no Parser area, so ALL of the script strings were shown as translatable.)

Thanks for your suggestion to create an XML file type, but unfortunately, this won't work because the scripts are included at the bottom of regular HTML files, containing regular HTML code. So these have to be treated as HTML file types.

I'm not able to share the files, unfortunately, but I'll recreate the relevant parts and paste a sample below. The translatable content is easily identifiable: It always falls between:

content: "

and

",

Thanks for your offer to look at it! There are a bunch of these files, so any method you can think of to automate the process is appreciated!

<!DOCTYPE html>
<html>
<head>
<title>Example of Embedded JS</title>
</head>
<body>

Regular HTML Here
Regular HTML Here
Regular HTML Here
Regular HTML Here

<script>
var hopscotch_steps = [{
target: "#clickTarget",
placement: "top",
showNextButton: false,
content: "<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><p class=\"instruction\"><i class=\"fa fa-hand-o-up\"></i> Click <em>Add appliances</em> now.</p> ",
onShow: ["navigateToNextCourseActivity"]
}];
var tour = {
id: "Addappliances",
.
.
.
onEnd: ["activityCompleted"]
};
$(".click_target").on("click", hopscotch.jumpToTarget);
$("#beginBtn").on("click", function(e){
e.preventDefault();
hopscotch.startTour(tour);
});

</script>
</body>
</html>
Collapse


 
RWS Community
RWS Community
United Kingdom
Local time: 10:43
English
Workaround for now May 27, 2014

Hi,

We will be adding support for scripts in html in a future release, soon I hope (this year anyway), but in the meantime I managed to handle your file like this:

  1. Create a regex-based filetype to extract only the script part of the html file and include as an available filetype (but deactivated) for your Projects
  2. Create your Project and add the html file(s).
  3. Trans... See more
Hi,

We will be adding support for scripts in html in a future release, soon I hope (this year anyway), but in the meantime I managed to handle your file like this:

  1. Create a regex-based filetype to extract only the script part of the html file and include as an available filetype (but deactivated) for your Projects
  2. Create your Project and add the html file(s).
  3. Translate the files as html files and save the target files
  4. Rename the target files, activate the script filetype you created, and add the translated files files to your project so you can now do the script part
  5. Translate the files and save target
  6. Rename the target files again so they are what you need and the job is complete

So it is a little fiddly, but doable.

Regards

Paul
Collapse


 
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
TOPIC STARTER
I'll give it a try... May 27, 2014

Paul, thank you for taking the time to come up with this method.

I'm looking forward to the next release, which will allow scripts in html to be translated, but I will give your method a try. I've not created a regex-based filetype before. Can you point me in the right direction to a get started? I very much appreciate your help!

David


 
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
TOPIC STARTER
Very helpful link... May 28, 2014

Paul,
Your video about using the regex file type was very helpful. So I'm in good shape to try your method above. I made a Regex file type with the following properties:

Document structure -> Opening pattern: .*content: "
Document structure -> Closing pattern: ",$
Inline tags -> Rule Type:Tag pair
Inline tags -> Rule -> Opening: <.+?>
Inline tags -> Rule -> Closin
... See more
Paul,
Your video about using the regex file type was very helpful. So I'm in good shape to try your method above. I made a Regex file type with the following properties:

Document structure -> Opening pattern: .*content: "
Document structure -> Closing pattern: ",$
Inline tags -> Rule Type:Tag pair
Inline tags -> Rule -> Opening: <.+?>
Inline tags -> Rule -> Closing: <//.+?>
Properties -> Tranlate: Always translatable


This does the trick. I've checked many files and it selects exactly the text that needs to be translated.

I'm looking forward to the day where this can be done in one pass (i.e. be able to translate both the html and javascript strings contained in a single document at one time) but I think this is a good temporary fix.

Thank you very much for your help!

David
Collapse


 
RWS Community
RWS Community
United Kingdom
Local time: 10:43
English
Nice work! May 28, 2014

Hi David,

Thanks for posting back, and with your solution. Good to see this worked for you. I'm also looking forward to every improved feature we release!

Regards

Paul


 
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
TOPIC STARTER
Follow-up question May 28, 2014

Paul, thanks again for helping me solve this problem. Now a follow-up question, if you don't mind: Do you know why Studio 2014 completely ignores all strings within script tags, even though the tag is included in the HTML > Parser settings, and presumably allows strings therein to be translatable? In Studio 2011, this setting is not available, but 2011 does treat ALL strings within script tags as translatable. Is this is bug? Or maybe I'm misunderstanding something?

Thanks,
Da
... See more
Paul, thanks again for helping me solve this problem. Now a follow-up question, if you don't mind: Do you know why Studio 2014 completely ignores all strings within script tags, even though the tag is included in the HTML > Parser settings, and presumably allows strings therein to be translatable? In Studio 2011, this setting is not available, but 2011 does treat ALL strings within script tags as translatable. Is this is bug? Or maybe I'm misunderstanding something?

Thanks,
David
Collapse


 
Rikkom
Rikkom
United States
Local time: 04:43
Has HTML script support been added yet? May 21, 2015

Hello,

Does any one know if HTML script support been added now? I am using Studio 2014 SP2 - 11.2.4409.10

Thank you!


 
ajitrans
ajitrans  Identity Verified
United States
Local time: 02:43
TOPIC STARTER
Good question! May 21, 2015

Thanks for inquiring about this, Rikkom. I'm desperately hoping that support for this will come soon too, especially because the project that originally prompted this question has come up again in full force. Paul, do you have any word on this?
David


 
Translating javascript within html/resx files Studio 2015 Sep 12, 2017

Have there been any developments regarding this issue? I stumbled upon the same issue with Studio 2015. Maybe it has been added for Studio 2017? Or does anyone know of other solutions?

 


To report site rules violations or get help, contact a site moderator:


You can also contact site staff by submitting a support request »

Translating javascript within html files, Studio 2014







Anycount & Translation Office 3000
Translation Office 3000

Translation Office 3000 is an advanced accounting tool for freelance translators and small agencies. TO3000 easily and seamlessly integrates with the business life of professional freelance translators.

More info »
Trados Business Manager Lite
Create customer quotes and invoices from within Trados Studio

Trados Business Manager Lite helps to simplify and speed up some of the daily tasks, such as invoicing and reporting, associated with running your freelance translation business.

More info »