Hi there,
i'm trying to make 2 scripts to convert between IOS and Android i18n 
formats to work. I've gotten Android -> IOS to work, but the other way 
around is a challenge.

Basically, for each row in a file i want to convert
*"login_infoLabel" = "Do you need help? Press here.”;*
to
*<string name="login_infoLabel">Do you need help? Press here.</string*

See my script below. The problem is the first search string to find the 
first " on each row. I spoke with Patrik at BBEdit and he kindly informed 
me that it was because AppleScript doesn't support grep and that i should 
instead record my replace with the script editor. 

I did that, but now i'm at a loss as to how combine these two snippets, 
where one is apple script and one is not?

Also, the 'record' contains the actual file name, how do i make the script 
just use the file showing in the window as i do with the apple script?

If anyone could point me in the right direction, i'd be most thankful.

*My replace "recording":*
replace "^\"" using "<string name=\\\"" searching in text 1 of text 
document "untitled text 133" options {search mode:grep, starting at 
top:true}


*My Apple script (the first item in search_strings is what won't work):*
set search_strings to {*"^\""*, "\" = \"", "\";"}
set replace_strings to {"<string name=\"", "\">", "</string>"}

tell application "BBEdit"
set the_string to (selection of front window as string)
repeat with i from 1 to (count search_strings)
set the_string to my snr(the_string, item i of search_strings, item i of 
replace_strings)
end repeat
--set the clipboard to the_string
set selection of front window to the_string
end tell

on snr(the_string, search_string, replace_string)
tell (a reference to my text item delimiters)
set {old_atid, contents} to {contents, search_string}
set {the_string, contents} to {the_string's text items, replace_string}
set {the_string, contents} to {"" & the_string, old_atid}
end tell
return the_string
end snr

The 'record' from BBEdit:

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/1c337d31-e00e-441b-9da6-1c7b9fd71528n%40googlegroups.com.

Reply via email to