I have updated my answer.
Yes it can be done by using low-level XeTeX, but the implementation is different, according to the packages used (polyglossia or xgreek). The technique is explained in xetex-reference page 14 and in A. Syropoylos book Ψηφιακή τυπογραφία με το XeLaTeX
(in greek).
For the short answer, just look at the Answer
section.
The downside with the approach used here is that you can't use more than one greek variant in your text (monogreek, polygreek, ancientgreek). You have to choose one. If you care just for the hyphenation rules then I don't think it really matters.
First of all, create a file named greektokens.tex
with the following contents. It contains characters from the greek and coptic
and greek extended
unicode blocks.
\XeTeXinterchartokenstate=1
\newXeTeXintercharclass \greekLetter
% greek and coptic glyphs
\XeTeXcharclass `\Ͱ \greekLetter
\XeTeXcharclass `\ͱ \greekLetter
\XeTeXcharclass `\Ͳ \greekLetter
\XeTeXcharclass `\ͳ \greekLetter
\XeTeXcharclass `\ʹ \greekLetter
\XeTeXcharclass `\͵ \greekLetter
\XeTeXcharclass `\Ͷ \greekLetter
\XeTeXcharclass `\ͷ \greekLetter
\XeTeXcharclass `\ͺ \greekLetter
\XeTeXcharclass `\ͻ \greekLetter
\XeTeXcharclass `\ͼ \greekLetter
\XeTeXcharclass `\ͽ \greekLetter
\XeTeXcharclass `\; \greekLetter
\XeTeXcharclass `\΄ \greekLetter
\XeTeXcharclass `\΅ \greekLetter
\XeTeXcharclass `\Ά \greekLetter
\XeTeXcharclass `\· \greekLetter
\XeTeXcharclass `\Έ \greekLetter
\XeTeXcharclass `\Ή \greekLetter
\XeTeXcharclass `\Ί \greekLetter
\XeTeXcharclass `\Ό \greekLetter
\XeTeXcharclass `\Ύ \greekLetter
\XeTeXcharclass `\Ώ \greekLetter
\XeTeXcharclass `\ΐ \greekLetter
\XeTeXcharclass `\Α \greekLetter
\XeTeXcharclass `\Β \greekLetter
\XeTeXcharclass `\Γ \greekLetter
\XeTeXcharclass `\Δ \greekLetter
\XeTeXcharclass `\Ε \greekLetter
\XeTeXcharclass `\Ζ \greekLetter
\XeTeXcharclass `\Η \greekLetter
\XeTeXcharclass `\Θ \greekLetter
\XeTeXcharclass `\Ι \greekLetter
\XeTeXcharclass `\Κ \greekLetter
\XeTeXcharclass `\Λ \greekLetter
\XeTeXcharclass `\Μ \greekLetter
\XeTeXcharclass `\Ν \greekLetter
\XeTeXcharclass `\Ξ \greekLetter
\XeTeXcharclass `\Ο \greekLetter
\XeTeXcharclass `\Π \greekLetter
\XeTeXcharclass `\Ρ \greekLetter
\XeTeXcharclass `\Σ \greekLetter
\XeTeXcharclass `\Τ \greekLetter
\XeTeXcharclass `\Υ \greekLetter
\XeTeXcharclass `\Φ \greekLetter
\XeTeXcharclass `\Χ \greekLetter
\XeTeXcharclass `\Ψ \greekLetter
\XeTeXcharclass `\Ω \greekLetter
\XeTeXcharclass `\Ϊ \greekLetter
\XeTeXcharclass `\Ϋ \greekLetter
\XeTeXcharclass `\ά \greekLetter
\XeTeXcharclass `\έ \greekLetter
\XeTeXcharclass `\ή \greekLetter
\XeTeXcharclass `\ί \greekLetter
\XeTeXcharclass `\ΰ \greekLetter
\XeTeXcharclass `\α \greekLetter
\XeTeXcharclass `\β \greekLetter
\XeTeXcharclass `\γ \greekLetter
\XeTeXcharclass `\δ \greekLetter
\XeTeXcharclass `\ε \greekLetter
\XeTeXcharclass `\ζ \greekLetter
\XeTeXcharclass `\η \greekLetter
\XeTeXcharclass `\θ \greekLetter
\XeTeXcharclass `\ι \greekLetter
\XeTeXcharclass `\κ \greekLetter
\XeTeXcharclass `\λ \greekLetter
\XeTeXcharclass `\μ \greekLetter
\XeTeXcharclass `\ν \greekLetter
\XeTeXcharclass `\ξ \greekLetter
\XeTeXcharclass `\ο \greekLetter
\XeTeXcharclass `\π \greekLetter
\XeTeXcharclass `\ρ \greekLetter
\XeTeXcharclass `\ς \greekLetter
\XeTeXcharclass `\σ \greekLetter
\XeTeXcharclass `\τ \greekLetter
\XeTeXcharclass `\υ \greekLetter
\XeTeXcharclass `\φ \greekLetter
\XeTeXcharclass `\χ \greekLetter
\XeTeXcharclass `\ψ \greekLetter
\XeTeXcharclass `\ω \greekLetter
\XeTeXcharclass `\ϊ \greekLetter
\XeTeXcharclass `\ϋ \greekLetter
\XeTeXcharclass `\ό \greekLetter
\XeTeXcharclass `\ύ \greekLetter
\XeTeXcharclass `\ώ \greekLetter
\XeTeXcharclass `\Ϗ \greekLetter
\XeTeXcharclass `\ϐ \greekLetter
\XeTeXcharclass `\ϑ \greekLetter
\XeTeXcharclass `\ϒ \greekLetter
\XeTeXcharclass `\ϓ \greekLetter
\XeTeXcharclass `\ϔ \greekLetter
\XeTeXcharclass `\ϕ \greekLetter
\XeTeXcharclass `\ϖ \greekLetter
\XeTeXcharclass `\ϗ \greekLetter
\XeTeXcharclass `\Ϙ \greekLetter
\XeTeXcharclass `\ϙ \greekLetter
\XeTeXcharclass `\Ϛ \greekLetter
\XeTeXcharclass `\ϛ \greekLetter
\XeTeXcharclass `\Ϝ \greekLetter
\XeTeXcharclass `\ϝ \greekLetter
\XeTeXcharclass `\Ϟ \greekLetter
\XeTeXcharclass `\ϟ \greekLetter
\XeTeXcharclass `\Ϡ \greekLetter
\XeTeXcharclass `\ϡ \greekLetter
\XeTeXcharclass `\Ϣ \greekLetter
\XeTeXcharclass `\ϣ \greekLetter
\XeTeXcharclass `\Ϥ \greekLetter
\XeTeXcharclass `\ϥ \greekLetter
\XeTeXcharclass `\Ϧ \greekLetter
\XeTeXcharclass `\ϧ \greekLetter
\XeTeXcharclass `\Ϩ \greekLetter
\XeTeXcharclass `\ϩ \greekLetter
\XeTeXcharclass `\Ϫ \greekLetter
\XeTeXcharclass `\ϫ \greekLetter
\XeTeXcharclass `\Ϭ \greekLetter
\XeTeXcharclass `\ϭ \greekLetter
\XeTeXcharclass `\Ϯ \greekLetter
\XeTeXcharclass `\ϯ \greekLetter
\XeTeXcharclass `\ϰ \greekLetter
\XeTeXcharclass `\ϱ \greekLetter
\XeTeXcharclass `\ϲ \greekLetter
\XeTeXcharclass `\ϳ \greekLetter
\XeTeXcharclass `\ϴ \greekLetter
\XeTeXcharclass `\ϵ \greekLetter
\XeTeXcharclass `\϶ \greekLetter
\XeTeXcharclass `\Ϸ \greekLetter
\XeTeXcharclass `\ϸ \greekLetter
\XeTeXcharclass `\Ϲ \greekLetter
\XeTeXcharclass `\Ϻ \greekLetter
\XeTeXcharclass `\ϻ \greekLetter
\XeTeXcharclass `\ϼ \greekLetter
\XeTeXcharclass `\Ͻ \greekLetter
\XeTeXcharclass `\Ͼ \greekLetter
\XeTeXcharclass `\Ͽ \greekLetter
% greek extended glyphs
\XeTeXcharclass `\ἀ \greekLetter
\XeTeXcharclass `\ἁ \greekLetter
\XeTeXcharclass `\ἂ \greekLetter
\XeTeXcharclass `\ἃ \greekLetter
\XeTeXcharclass `\ἄ \greekLetter
\XeTeXcharclass `\ἅ \greekLetter
\XeTeXcharclass `\ἆ \greekLetter
\XeTeXcharclass `\ἇ \greekLetter
\XeTeXcharclass `\Ἀ \greekLetter
\XeTeXcharclass `\Ἁ \greekLetter
\XeTeXcharclass `\Ἂ \greekLetter
\XeTeXcharclass `\Ἃ \greekLetter
\XeTeXcharclass `\Ἄ \greekLetter
\XeTeXcharclass `\Ἅ \greekLetter
\XeTeXcharclass `\Ἆ \greekLetter
\XeTeXcharclass `\Ἇ \greekLetter
\XeTeXcharclass `\ἐ \greekLetter
\XeTeXcharclass `\ἑ \greekLetter
\XeTeXcharclass `\ἒ \greekLetter
\XeTeXcharclass `\ἓ \greekLetter
\XeTeXcharclass `\ἔ \greekLetter
\XeTeXcharclass `\ἕ \greekLetter
\XeTeXcharclass `\Ἐ \greekLetter
\XeTeXcharclass `\Ἑ \greekLetter
\XeTeXcharclass `\Ἒ \greekLetter
\XeTeXcharclass `\Ἓ \greekLetter
\XeTeXcharclass `\Ἔ \greekLetter
\XeTeXcharclass `\Ἕ \greekLetter
\XeTeXcharclass `\ἠ \greekLetter
\XeTeXcharclass `\ἡ \greekLetter
\XeTeXcharclass `\ἢ \greekLetter
\XeTeXcharclass `\ἣ \greekLetter
\XeTeXcharclass `\ἤ \greekLetter
\XeTeXcharclass `\ἥ \greekLetter
\XeTeXcharclass `\ἦ \greekLetter
\XeTeXcharclass `\ἧ \greekLetter
\XeTeXcharclass `\Ἠ \greekLetter
\XeTeXcharclass `\Ἡ \greekLetter
\XeTeXcharclass `\Ἢ \greekLetter
\XeTeXcharclass `\Ἣ \greekLetter
\XeTeXcharclass `\Ἤ \greekLetter
\XeTeXcharclass `\Ἥ \greekLetter
\XeTeXcharclass `\Ἦ \greekLetter
\XeTeXcharclass `\Ἧ \greekLetter
\XeTeXcharclass `\ἰ \greekLetter
\XeTeXcharclass `\ἱ \greekLetter
\XeTeXcharclass `\ἲ \greekLetter
\XeTeXcharclass `\ἳ \greekLetter
\XeTeXcharclass `\ἴ \greekLetter
\XeTeXcharclass `\ἵ \greekLetter
\XeTeXcharclass `\ἶ \greekLetter
\XeTeXcharclass `\ἷ \greekLetter
\XeTeXcharclass `\Ἰ \greekLetter
\XeTeXcharclass `\Ἱ \greekLetter
\XeTeXcharclass `\Ἲ \greekLetter
\XeTeXcharclass `\Ἳ \greekLetter
\XeTeXcharclass `\Ἴ \greekLetter
\XeTeXcharclass `\Ἵ \greekLetter
\XeTeXcharclass `\Ἶ \greekLetter
\XeTeXcharclass `\Ἷ \greekLetter
\XeTeXcharclass `\ὀ \greekLetter
\XeTeXcharclass `\ὁ \greekLetter
\XeTeXcharclass `\ὂ \greekLetter
\XeTeXcharclass `\ὃ \greekLetter
\XeTeXcharclass `\ὄ \greekLetter
\XeTeXcharclass `\ὅ \greekLetter
\XeTeXcharclass `\Ὀ \greekLetter
\XeTeXcharclass `\Ὁ \greekLetter
\XeTeXcharclass `\Ὂ \greekLetter
\XeTeXcharclass `\Ὃ \greekLetter
\XeTeXcharclass `\Ὄ \greekLetter
\XeTeXcharclass `\Ὅ \greekLetter
\XeTeXcharclass `\ὐ \greekLetter
\XeTeXcharclass `\ὑ \greekLetter
\XeTeXcharclass `\ὒ \greekLetter
\XeTeXcharclass `\ὓ \greekLetter
\XeTeXcharclass `\ὔ \greekLetter
\XeTeXcharclass `\ὕ \greekLetter
\XeTeXcharclass `\ὖ \greekLetter
\XeTeXcharclass `\ὗ \greekLetter
\XeTeXcharclass `\Ὑ \greekLetter
\XeTeXcharclass `\Ὓ \greekLetter
\XeTeXcharclass `\Ὕ \greekLetter
\XeTeXcharclass `\Ὗ \greekLetter
\XeTeXcharclass `\ὠ \greekLetter
\XeTeXcharclass `\ὡ \greekLetter
\XeTeXcharclass `\ὢ \greekLetter
\XeTeXcharclass `\ὣ \greekLetter
\XeTeXcharclass `\ὤ \greekLetter
\XeTeXcharclass `\ὥ \greekLetter
\XeTeXcharclass `\ὦ \greekLetter
\XeTeXcharclass `\ὧ \greekLetter
\XeTeXcharclass `\Ὠ \greekLetter
\XeTeXcharclass `\Ὡ \greekLetter
\XeTeXcharclass `\Ὢ \greekLetter
\XeTeXcharclass `\Ὣ \greekLetter
\XeTeXcharclass `\Ὤ \greekLetter
\XeTeXcharclass `\Ὥ \greekLetter
\XeTeXcharclass `\Ὦ \greekLetter
\XeTeXcharclass `\Ὧ \greekLetter
\XeTeXcharclass `\ὰ \greekLetter
\XeTeXcharclass `\ά \greekLetter
\XeTeXcharclass `\ὲ \greekLetter
\XeTeXcharclass `\έ \greekLetter
\XeTeXcharclass `\ὴ \greekLetter
\XeTeXcharclass `\ή \greekLetter
\XeTeXcharclass `\ὶ \greekLetter
\XeTeXcharclass `\ί \greekLetter
\XeTeXcharclass `\ὸ \greekLetter
\XeTeXcharclass `\ό \greekLetter
\XeTeXcharclass `\ὺ \greekLetter
\XeTeXcharclass `\ύ \greekLetter
\XeTeXcharclass `\ὼ \greekLetter
\XeTeXcharclass `\ώ \greekLetter
\XeTeXcharclass `\ᾀ \greekLetter
\XeTeXcharclass `\ᾁ \greekLetter
\XeTeXcharclass `\ᾂ \greekLetter
\XeTeXcharclass `\ᾃ \greekLetter
\XeTeXcharclass `\ᾄ \greekLetter
\XeTeXcharclass `\ᾅ \greekLetter
\XeTeXcharclass `\ᾆ \greekLetter
\XeTeXcharclass `\ᾇ \greekLetter
\XeTeXcharclass `\ᾈ \greekLetter
\XeTeXcharclass `\ᾉ \greekLetter
\XeTeXcharclass `\ᾊ \greekLetter
\XeTeXcharclass `\ᾋ \greekLetter
\XeTeXcharclass `\ᾌ \greekLetter
\XeTeXcharclass `\ᾍ \greekLetter
\XeTeXcharclass `\ᾎ \greekLetter
\XeTeXcharclass `\ᾏ \greekLetter
\XeTeXcharclass `\ᾐ \greekLetter
\XeTeXcharclass `\ᾑ \greekLetter
\XeTeXcharclass `\ᾒ \greekLetter
\XeTeXcharclass `\ᾓ \greekLetter
\XeTeXcharclass `\ᾔ \greekLetter
\XeTeXcharclass `\ᾕ \greekLetter
\XeTeXcharclass `\ᾖ \greekLetter
\XeTeXcharclass `\ᾗ \greekLetter
\XeTeXcharclass `\ᾘ \greekLetter
\XeTeXcharclass `\ᾙ \greekLetter
\XeTeXcharclass `\ᾚ \greekLetter
\XeTeXcharclass `\ᾛ \greekLetter
\XeTeXcharclass `\ᾜ \greekLetter
\XeTeXcharclass `\ᾝ \greekLetter
\XeTeXcharclass `\ᾞ \greekLetter
\XeTeXcharclass `\ᾟ \greekLetter
\XeTeXcharclass `\ᾠ \greekLetter
\XeTeXcharclass `\ᾡ \greekLetter
\XeTeXcharclass `\ᾢ \greekLetter
\XeTeXcharclass `\ᾣ \greekLetter
\XeTeXcharclass `\ᾤ \greekLetter
\XeTeXcharclass `\ᾥ \greekLetter
\XeTeXcharclass `\ᾦ \greekLetter
\XeTeXcharclass `\ᾧ \greekLetter
\XeTeXcharclass `\ᾨ \greekLetter
\XeTeXcharclass `\ᾩ \greekLetter
\XeTeXcharclass `\ᾪ \greekLetter
\XeTeXcharclass `\ᾫ \greekLetter
\XeTeXcharclass `\ᾬ \greekLetter
\XeTeXcharclass `\ᾭ \greekLetter
\XeTeXcharclass `\ᾮ \greekLetter
\XeTeXcharclass `\ᾯ \greekLetter
\XeTeXcharclass `\ᾰ \greekLetter
\XeTeXcharclass `\ᾱ \greekLetter
\XeTeXcharclass `\ᾲ \greekLetter
\XeTeXcharclass `\ᾳ \greekLetter
\XeTeXcharclass `\ᾴ \greekLetter
\XeTeXcharclass `\ᾶ \greekLetter
\XeTeXcharclass `\ᾷ \greekLetter
\XeTeXcharclass `\Ᾰ \greekLetter
\XeTeXcharclass `\Ᾱ \greekLetter
\XeTeXcharclass `\Ὰ \greekLetter
\XeTeXcharclass `\Ά \greekLetter
\XeTeXcharclass `\ᾼ \greekLetter
\XeTeXcharclass `\᾽ \greekLetter
\XeTeXcharclass `\ι \greekLetter
\XeTeXcharclass `\᾿ \greekLetter
\XeTeXcharclass `\῀ \greekLetter
\XeTeXcharclass `\῁ \greekLetter
\XeTeXcharclass `\ῂ \greekLetter
\XeTeXcharclass `\ῃ \greekLetter
\XeTeXcharclass `\ῄ \greekLetter
\XeTeXcharclass `\ῆ \greekLetter
\XeTeXcharclass `\ῇ \greekLetter
\XeTeXcharclass `\Ὲ \greekLetter
\XeTeXcharclass `\Έ \greekLetter
\XeTeXcharclass `\Ὴ \greekLetter
\XeTeXcharclass `\Ή \greekLetter
\XeTeXcharclass `\ῌ \greekLetter
\XeTeXcharclass `\῍ \greekLetter
\XeTeXcharclass `\῎ \greekLetter
\XeTeXcharclass `\῏ \greekLetter
\XeTeXcharclass `\ῐ \greekLetter
\XeTeXcharclass `\ῑ \greekLetter
\XeTeXcharclass `\ῒ \greekLetter
\XeTeXcharclass `\ΐ \greekLetter
\XeTeXcharclass `\ῖ \greekLetter
\XeTeXcharclass `\ῗ \greekLetter
\XeTeXcharclass `\Ῐ \greekLetter
\XeTeXcharclass `\Ῑ \greekLetter
\XeTeXcharclass `\Ὶ \greekLetter
\XeTeXcharclass `\Ί \greekLetter
\XeTeXcharclass `\῝ \greekLetter
\XeTeXcharclass `\῞ \greekLetter
\XeTeXcharclass `\῟ \greekLetter
\XeTeXcharclass `\ῠ \greekLetter
\XeTeXcharclass `\ῡ \greekLetter
\XeTeXcharclass `\ῢ \greekLetter
\XeTeXcharclass `\ΰ \greekLetter
\XeTeXcharclass `\ῤ \greekLetter
\XeTeXcharclass `\ῥ \greekLetter
\XeTeXcharclass `\ῦ \greekLetter
\XeTeXcharclass `\ῧ \greekLetter
\XeTeXcharclass `\Ῠ \greekLetter
\XeTeXcharclass `\Ῡ \greekLetter
\XeTeXcharclass `\Ὺ \greekLetter
\XeTeXcharclass `\Ύ \greekLetter
\XeTeXcharclass `\Ῥ \greekLetter
\XeTeXcharclass `\῭ \greekLetter
\XeTeXcharclass `\΅ \greekLetter
\XeTeXcharclass `\` \greekLetter
\XeTeXcharclass `\ῲ \greekLetter
\XeTeXcharclass `\ῳ \greekLetter
\XeTeXcharclass `\ῴ \greekLetter
\XeTeXcharclass `\ῶ \greekLetter
\XeTeXcharclass `\ῷ \greekLetter
\XeTeXcharclass `\Ὸ \greekLetter
\XeTeXcharclass `\Ό \greekLetter
\XeTeXcharclass `\Ὼ \greekLetter
\XeTeXcharclass `\Ώ \greekLetter
\XeTeXcharclass `\ῼ \greekLetter
\XeTeXcharclass `\´ \greekLetter
\XeTeXcharclass `\῾ \greekLetter
There are 3 major cases.
- Polyglossia with greek as a secondary language (it will interest mostly non-greeks).
- Polyglossia with greek as a main language (it is propably better just to use xgreek).
- Xgreek (to be used for greek texts).
Polyglossia and greek as secondary language
Just put in your preamble the following code and everything should work out of the box.
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguages{basque,greek}
\input{greektokens.tex}
\XeTeXinterchartoks 0 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 0 = {\end{otherlanguage*}}
\XeTeXinterchartoks 255 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 255 = {\end{otherlanguage*}}
Polyglossia and greek as Main Language
In this case, only one language that uses the latin script can be typeset. I'll use basque for the following example.
I prefer to use xgreek
rather than polyglossia
as it seems to be more complete and mature. I haven't thorougly tested this option, so there might be problems. Polyglossia
is known to have some slight bugs with the greek language (June 2011).
\newcommand{\secondarylanguage}{basque}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguages{\secondarylanguage}
\input{greektokens.tex}
\XeTeXinterchartoks 0 \greekLetter = {\selectlanguage{greek}}
\XeTeXinterchartoks 255 \greekLetter = {\selectlanguage{greek}}
\XeTeXinterchartoks 255 0 = {\selectlanguage{\secondarylanguage}}
Xgreek
The third options uses xgreek
which is a package used for typesetting greek texts. In this case, as in the previous one, only one language using the latin script can be used. I will use again basque.
\newcommand{\greekvariant}{monogreek} % or polygreek or ancientgreek
\newcommand{\secondlanguage}{basque}
\usepackage[\greekvariant]{xgreek}
\input{greektokens.tex}
\XeTeXinterchartoks 0 \greekLetter = {\setlanguage{\greekvariant}}
\XeTeXinterchartoks \greekLetter 0 = {\setlanguage{\secondlanguage}}
\XeTeXinterchartoks 255 \greekLetter = {\setlanguage{\greekvariant}}
\XeTeXinterchartoks \greekLetter 255 = {\setlanguage{\secondlanguage}}
Answer
the following mwe is the actual answer to your question :)
\documentclass[12pt,draft]{article}
\usepackage{fontspec}
\setmainfont{Minion Pro}
\newfontfamily\greekfont{Kerkis}
\input{greektokens.tex}
\usepackage{polyglossia}
\setmainlanguage{english}
\setotherlanguage{greek}
\XeTeXinterchartoks 0 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 0 = {\end{otherlanguage*}}
\XeTeXinterchartoks 255 \greekLetter = {\begin{otherlanguage*}{greek}}
\XeTeXinterchartoks \greekLetter 255 = {\end{otherlanguage*}}
\begin{document}
Just some english text. And now some inline greek. Χωρίς ενοχλητικές δηλώσεις γλώσσας!!!
And again some english text. Continuing to show the hyphenation.
\end{document}
Request
In case you try any of the three approaches and you run into problems please report them as comments. If everything works ok, perhaps a package could be made out of it.