Skip to content

Commit

Permalink
Merge pull request #1 from litan/master
Browse files Browse the repository at this point in the history
Pull in the Turkish Level 2 wiring by Lalit
  • Loading branch information
bulent2k2 authored Oct 23, 2020
2 parents cbade13 + cdfd258 commit eb8c12a
Show file tree
Hide file tree
Showing 8 changed files with 360 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

* The [Kojo home-page][1] provides user-level information about Kojo.
* The [Kojo issue-tracker][3] let's you file bug reports.
* The [Kojo Localization][5] page tells you how to translate Kojo to your language.
* The [Kojo Localization](localization.md) page tells you how to translate Kojo to your language.

**To start hacking:**

Expand Down
6 changes: 4 additions & 2 deletions l10n-level2/gen-level2.kojo
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import net.kogics.kojo.util.RichFile.enrichFile

clearOutput()

val kojoDir = "/home/lalit/kojo-2.11"
val kojoDir = "/home/lalit/work/kojo"
val targetLangCode = "tr"

val templateFile = s"$kojoDir/l10n-level2/langInit.scala.template"
val replacementsFile = s"$kojoDir/l10n-level2/level2_it.properties"
val replacementsFile = s"$kojoDir/l10n-level2/level2_$targetLangCode.properties"

val varPattern = """\$\$(.*?)\$"""
val pattern = Pattern.compile(varPattern)
Expand Down
47 changes: 47 additions & 0 deletions localization.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Kojo can be localized at three levels.

* Level 1 - localization of the UI
* Level 2 - localization of the basic turtle and looping commands (so that children can program in the target language).
* Level 3 - localization of the existing turtle graphics samples.

The following are the steps that need to be followed to do the localization:

The first step is to fork and then clone the kojo repo. You can then make the required localization enhancements in your repo and send pull requests.

In the discussion below, let's assume that the language code for the target language is `xx`.

### Level 1
Create `Bundle_xx.properties` by tanslating the following file:
https://github.com/litan/kojo/blob/master/src/main/resources/net/kogics/kojo/lite/Bundle.properties

Add your language code to the list here:
https://github.com/litan/kojo/blob/master/src/main/scala/net/kogics/kojo/lite/LangMenuFactory.scala#L31

Add your language (localized) name to the map here:
https://github.com/litan/kojo/blob/master/src/main/scala/net/kogics/kojo/lite/LangMenuFactory.scala#L75

Then send a pull request.

### Level 2
Create `level2_xx.properties` by translating the following file:
https://github.com/litan/kojo/blob/master/l10n-level2/level2.properties

Then send a pull request.

FYI, with the help of `level2_xx.properties`, the following files will be modified by a Kojo core-developer to wire in the level-2 changes:
* xxInit.scala (generated from the above properties file).
* xx.tw.scala
* LangInit.scala

Here's an example checkin for a wiring-in:
https://github.com/litan/kojo/commit/852c18a6124fe773063f846db8fda9b7b705ab4c

### Level 3
This is best explained with an example:

if you want to localize the following sample for Swedish:
`src/main/resources/samples/spiral.kojo`
Then you just need to just create the following localized version of the sample:
`src/main/resources/samples/sv/spiral.kojo`
The version of spiral.kojo under the sv directory will get picked up when Kojo is running in Swedish mode.

24 changes: 24 additions & 0 deletions src/main/resources/i18n/initk/tr.tw.kojo
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (C) 2013
* Bjorn Regnell <[email protected]>,
* Lalit Pant <[email protected]>
*
* The contents of this file are subject to the GNU General Public License
* Version 3 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.gnu.org/copyleft/gpl.html
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
*/

// Turkish Turtle wrapper init for Kojo

// make Turkish names visible
val TurkishAPI = net.kogics.kojo.lite.i18n.TurkishAPI
import TurkishAPI._
// hide turtle.clear
import kaplumbağa.{sil => _, _}
1 change: 1 addition & 0 deletions src/main/scala/net/kogics/kojo/lite/AppMenu.scala
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ trait AppMenu {
<li>Massimo Maria Ghisalberti</li>
<li>Luka Volaric</li>
<li>Marcus Klang</li>
<li>Bulent Basaran</li>
</ul>
<strong>Kojo</strong> is licensed under The GNU General Public License (GPL). The full text of the GPL is available at: http://www.gnu.org/licenses/gpl.html<br/><br/>
Kojo runs on the Java Platform.<br/><br/>
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/net/kogics/kojo/lite/LangMenuFactory.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import net.kogics.kojo.util.Utils
*/
object LangMenuFactory {

val supportedLanguages = List("en", "sv", "fr", "pl" , "nl", "eo", "hi", "de", "ru", "it", "hr")
val supportedLanguages = List("en", "sv", "fr", "pl" , "nl", "eo", "hi", "de", "ru", "it", "hr", "tr")

def createLangMenu()(implicit kojoCtx: core.KojoCtx) = {
var langMenus: Seq[JCheckBoxMenuItem] = Vector()
Expand Down Expand Up @@ -83,7 +83,8 @@ object LangMenuFactory {
"hi" -> "हिंदी (Hindi)",
"de" -> "Deutsch (German)",
"ru" -> "Русский (Russian)",
"hr" -> "Hrvatski (Croatian)"
"hr" -> "Hrvatski (Croatian)",
"tr" -> "Türkçe (Turkish)"
)

/** If the language code is not in this map, then the country defaults to same code as the language. */
Expand Down
2 changes: 2 additions & 0 deletions src/main/scala/net/kogics/kojo/lite/i18n/LangInit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ object LangInit {
ItInit.init(b)
case "hr" =>
hrInit.init(b)
case "tr" =>
TurkishInit.init(b)
case _ =>
}
}
Expand Down
Loading

0 comments on commit eb8c12a

Please sign in to comment.