Jump to content


Photo

Convert References Into Different Language


  • Please log in to reply
No replies to this topic

#1 ChristianB

ChristianB

    Bronze

  • Active Members
  • PipPip
  • 72 posts
  • Gender:Male
  • Accordance Version:10.x

Posted 21 January 2009 - 02:57 PM

Since the only output of references in Accordance is english I was looking for a way to convert this into German.

A friend wrote an Applescript for me to do that! If you have a little bit experience with Applescript you can change it to make it work for you.

Thanks also to Jospeh Weaks, who helped with another script and in a way inspired me for this idea.

--------------------------------------------------
--
--	developed by:
--				 :kelko:
--				 kelko < at > anakrino <.> de
--				 http://kelko.anakrino.de
--
--
--------------------------------------------------


--------------------------------------------------
-- Properties:
-- feel free to change the script into the language you need ... if you know what you are doing
-- You need to change the names in the "GermanBookList" ... make shure you have the right order of books
-- If you change the name itself make sure you change it throughout the script
-- Properties written by @ptujec
--------------------------------------------------


property NumberList : "1 | 2 | 3 | 4 | 5"

property EnglishBookString : "Gen | Ex | Lev | Num | Deut | Josh | Judg | Ruth | Sam | Kgs | Chr | Ezra | Neh | Esth | Job | Ps | Prov | Eccl | Song | Isa | Jer | Lam | Ezek | Dan | Hos | Joel | Amos | Obad | Jonah | Mic | Nah | Hab | Zeph | Hag | Zech | Mal | Matt | Mark | Luke | John | Acts | Rom | 1 Cor | 2 Cor | Gal | Eph | Phil | Col | Thess | Tim | Titus | Phlm | Heb | Jas | Pet | John | Jude | Rev"

property EnglishBookList : {"Gen", "Ex", "Lev", "Num", "Deut", "Josh", "Judg", "Ruth", "Sam", "Kgs", "Chr", "Ezra", "Neh", "Esth", "Job", "Ps", "Prov", "Eccl", "Song", "Isa", "Jer", "Lam", "Ezek", "Dan", "Hos", "Joel", "Amos", "Obad", "Jonah", "Mic", "Nah", "Hab", "Zeph", "Hag", "Zech", "Mal", "Matt", "Mark", "Luke", "John", "Acts", "Rom", "Cor", "Gal", "Eph", "Phil", "Col", "Thess", "Tim", "Titus", "Phlm", "Heb", "Jas", " Pet", "John", "Jude", "Rev"}

property GermanBookList : {"1 Mo", "2 Mo", "3 Mo", "4 Mo", "5 Mo", "Jos", "Ri", "Rut", "Sam", "Kö", "Chr", "Esr", "Neh", "Ester", "Hiob", "Ps", "Spr", "Pred", "Hl", "Jes", "Jer", "Kla", "Hes", "Dan", "Hos", "Joel", "Amos", "Ob", "Jona", "Mi", "Nah", "Hab", "Zef", "Hag", "Sach", "Mal", "Mt", "Mk", "Lk", "Joh", "Apg", "Röm", "Kor", "Gal", "Eph", "Phil", "Kol", "Thess", "Tim", "Tit", "Phim", "Heb", "Jak", "Petr", "Joh", "Jud", "Offb"}

--------------------------------------------------
-- Input via LaunchBar
--------------------------------------------------

-- If you rather use Quicksilver replace the following section "on handle_string ..." to "using terms from ..."
--
-- using terms from application "Quicksilver"
--			   on process text theString
--				   set theString to iterateThrough(theString)
--				   set the clipboard to theString
--			   end process text
-- end using terms from

on handle_string(theString)
	set theString to iterateThrough(theString)
	set the clipboard to theString
end handle_string

on iterateThrough(t)
	set newString to ""
	set offsetPos to 0
	
	repeat
		
		set offsetPos to offset of ";" in t
		
		if length of t = 0 then
			exit repeat
		end if
		
		set bookName to text 1 thru (offsetPos - 1) of t
		
		set bookName to convertEnglishBook2German(bookName)
		
		set newString to newString & bookName & "; "
		
		if offsetPos is equal to 0 then
			set t to ""
		else
			set t to text (offsetPos + 2) thru -1 of t
		end if
		
	end repeat
	
	
	return newString
end iterateThrough

--------------------------------------------------
-- Convert Input
--------------------------------------------------

on convertEnglishBook2German(t)
	
	set prefix to ""
	
	if text 1 of t is in NumberList and text 2 of t is equal to space then
		
		set prefix to (text 1 of t) & space
		set t to (text 3 thru -1 of t)
		
	end if
	
	
	
	set o to offset of space in t
	if o is equal to 0 then
		return prefix & t
	end if
	
	set bookName to text 1 thru (o - 1) of t
	if bookName is in EnglishBookString then
		repeat with n from 1 to (length of EnglishBookList)
			if (get item n of EnglishBookList) starts with bookName then
				-- replace any English Reference containing the Book string with the corresponding German Book title in the same place.
				set bookName to item n of GermanBookList
			end if
		end repeat
	end if
	return (prefix & bookName & text o thru -1 of t)
end convertEnglishBook2German

iterateThrough("Ps 40,9; Rom 5,8; 2 Cor 11,11; 13,11; Eph 6,23; Heb 6,10; 1 John 4,7-10.12.16.20")

Edited by ChristianB, 21 January 2009 - 06:27 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users