├── .github
└── workflows
│ └── android.yml
├── .gitignore
├── .gitmodules
├── CHANGELOG.MD
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── java
│ └── com
│ │ └── zqc
│ │ └── opencc
│ │ └── android
│ │ └── MainActivity.java
│ └── res
│ ├── layout
│ └── activity_main.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── colors.xml
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── lib-opencc-android
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── zqc
│ │ └── opencc
│ │ └── andorid
│ │ └── lib
│ │ └── ApplicationTest.java
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── openccdata
│ │ ├── HKVariants.ocd2
│ │ ├── HKVariantsRev.ocd2
│ │ ├── HKVariantsRevPhrases.ocd2
│ │ ├── JPShinjitaiCharacters.ocd2
│ │ ├── JPShinjitaiPhrases.ocd2
│ │ ├── JPVariants.ocd2
│ │ ├── JPVariantsRev.ocd2
│ │ ├── STCharacters.ocd2
│ │ ├── STPhrases.ocd2
│ │ ├── TSCharacters.ocd2
│ │ ├── TSPhrases.ocd2
│ │ ├── TWPhrases.ocd2
│ │ ├── TWPhrasesRev.ocd2
│ │ ├── TWVariants.ocd2
│ │ ├── TWVariantsRev.ocd2
│ │ ├── TWVariantsRevPhrases.ocd2
│ │ ├── hk2s.json
│ │ ├── hk2t.json
│ │ ├── jp2t.json
│ │ ├── s2hk.json
│ │ ├── s2t.json
│ │ ├── s2tw.json
│ │ ├── s2twp.json
│ │ ├── t2hk.json
│ │ ├── t2jp.json
│ │ ├── t2s.json
│ │ ├── t2tw.json
│ │ ├── tw2s.json
│ │ ├── tw2sp.json
│ │ ├── tw2t.json
│ │ └── zFinished2
│ ├── java
│ └── com
│ │ └── zqc
│ │ └── opencc
│ │ └── android
│ │ └── lib
│ │ ├── ChineseConverter.java
│ │ └── ConversionType.java
│ └── jni
│ ├── Android.mk
│ ├── Application.mk
│ └── chineseconverter.cpp
├── projectFilesBackup
└── .idea
│ └── workspace.xml
└── settings.gradle
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: ubuntu-latest
9 |
10 | steps:
11 | - name: check out code recursively
12 | uses: actions/checkout@v1
13 | with:
14 | submodules: recursive
15 | - name: set up JDK 1.8
16 | uses: actions/setup-java@v1
17 | with:
18 | java-version: 1.8
19 | - name: Build with Gradle
20 | run: |
21 | touch local.properties
22 | ./gradlew build
23 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/*
5 | .DS_Store
6 | /build
7 | /captures
8 | /*/out
9 | **/build/*
10 | **/.externalNativeBuild
11 | **/.cxx
12 | .project
13 | .settings/*
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "lib-opencc-android/src/main/jni/OpenCC"]
2 | path = lib-opencc-android/src/main/jni/OpenCC
3 | url = https://github.com/qichuan/OpenCC.git
4 |
--------------------------------------------------------------------------------
/CHANGELOG.MD:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## [1.2.0] - 2021-05-25
9 |
10 | ### Added
11 | - Update OpenCC dictionary data
12 | - Add hk2t support
13 | - Add jp2t support
14 | - Add t2jp support
15 | - Add tw2t support
16 |
17 | ### Changed
18 | - Replace ocd files with ocd2 files
19 |
20 | ## [1.1.0] - 2020-02-12
21 |
22 | ### Added
23 |
24 | - Update OpenCC data
25 |
26 | ## [1.0.0] - 2019-11-07
27 |
28 | ### Added
29 |
30 | - 1.0 release
31 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 ZHANG Qichuan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Introduction
2 |
3 | An Android port to [OPENCC](https://github.com/BYVoid/OpenCC), a library to convert Simplified Chinese to Traditional Chinese and vice versa. In additional, it also adopts the regional vocabulary and terminology interchangeably during conversion among Mainland China Simplified Chinese, Taiwan Traditional Chinese and Hong Kong Traditional Chinese.
4 |
5 | ## Note
6 | This project uses git submodules to download the source code from OpenCC, please use --recursive flag when cloning this project
7 |
8 | ```
9 | git clone git@github.com:qichuan/android-opencc.git --recursive
10 |
11 | ```
12 |
13 | ## Example
14 | ```
15 | 滑鼠裡面的矽二極體壞了,導致游標解析度降低。
16 | ```
17 | in Traditional Taiwan Chinese
18 | will be converted to
19 | ```
20 | 鼠标里面的硅二极管坏了,导致光标分辨率降低。
21 | ```
22 | in Simplified Chinese and using Mainland China terminology
23 |
24 | # Installation
25 |
26 | Add it in your root build.gradle at the end of repositories:
27 | ```
28 | allprojects {
29 | repositories {
30 | ...
31 | maven { url 'https://jitpack.io' }
32 | }
33 | }
34 | ```
35 |
36 | ```
37 | // Add the dependency
38 | dependencies {
39 | ...
40 | implementation 'com.github.qichuan:android-opencc:1.2.0'
41 | }
42 | ```
43 |
44 | # Usage
45 | To use Chinese converter is easy, just call `ChineseConverter.convert(originalText, conversionType, context));`
46 |
47 | ## Supported conversation types
48 | - HK2S, Traditional Chinese (Hong Kong Standard) to Simplified Chinese 香港繁體(香港小學學習字詞表標準)到簡體
49 | - HK2T, Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁體(香港小學學習字詞表標準)到繁體
50 | - JP2T, New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日本漢字到繁體
51 | - S2HK, Simplified Chinese to Traditional Chinese (Hong Kong Standard) 簡體到香港繁體(香港小學學習字詞表標準)
52 | - S2T, Simplified Chinese to Traditional Chinese 簡體到繁體
53 | - S2TW, Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體
54 | - S2TWP, Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
55 | - T2HK, Traditional Chinese to Traditional Chinese (Hong Kong Standard) 繁體到香港繁體(香港小學學習字詞表標準)
56 | - T2S, Traditional Chinese to Simplified Chinese 繁體到簡體
57 | - T2TW, Traditional Chinese to Traditional Chinese (Taiwan Standard) 繁體臺灣正體
58 | - TW2S, Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體
59 | - T2JP, Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁體到日本漢字
60 | - TW2T, Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體
61 | - TW2SP, Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙
62 |
63 | # Explanation
64 |
65 | android-opencc leverages on the original OpenCC project and invoke the native code via JNI, the text phrase dictionary files are shipped in the assets folder. Android NDK does not provide means to create and read file streams from directly from assets folder, therefore the dictionary files are then copied to the application data folder in the first call of `ChineseConverter.convert()`
66 |
67 | If you need to update the dictionary files in the assets folder, please remember to call `ChineseConverter.clearDictDataFolder()` once to clear the old dictionary files, so the new dictionary files will be effective in the next `ChineseConverter.convert()` call.
68 |
69 | # Compilation
70 |
71 | You need the Android NDK for compilation, please download the [NDK](http://developer.android.com/ndk/downloads/index.html) and configure the path to NDK in `local.properties` file.
72 |
73 | # Example apk
74 |
75 | [Download here](https://www.dropbox.com/s/0qzcmchqf5hqyit/android-opencc-0.6.0.apk?dl=1)
76 |
77 | Feel free to feedback if there are any issues, and hope this library can be useful for you.
78 |
79 | # References
80 | - https://github.com/BYVoid/OpenCC
81 | - https://github.com/gelosie/OpenCC/tree/master/iOS
82 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion = 30
5 | buildToolsVersion = "30.0.3"
6 | ndkVersion "21.1.6352462"
7 |
8 | defaultConfig {
9 | applicationId "com.zqc.opencc.android"
10 | minSdkVersion 15
11 | targetSdkVersion 30
12 | }
13 | }
14 |
15 | android.buildTypes {
16 | release {
17 | minifyEnabled = false
18 | proguardFiles.add(file('proguard-rules.txt'))
19 | }
20 | }
21 |
22 | dependencies {
23 | //implementation project(':lib-opencc-android')
24 | implementation 'com.github.qichuan:android-opencc:1.2.0'
25 | implementation 'androidx.appcompat:appcompat:1.3.0'
26 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangqichuan/dev/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zqc/opencc/android/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.zqc.opencc.android;
2 |
3 | import android.os.Bundle;
4 | import androidx.appcompat.app.AppCompatActivity;
5 | import android.view.View;
6 | import android.widget.AdapterView;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.EditText;
9 | import android.widget.Spinner;
10 |
11 | import com.zqc.opencc.android.lib.ChineseConverter;
12 | import com.zqc.opencc.android.lib.ConversionType;
13 |
14 | import java.util.concurrent.ExecutorService;
15 | import java.util.concurrent.Executors;
16 |
17 | public class MainActivity extends AppCompatActivity {
18 |
19 | private ConversionType currentConversionType = ConversionType.TW2SP;
20 |
21 | ExecutorService executorService = Executors.newSingleThreadExecutor();
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 |
28 | Spinner spinner = findViewById(R.id.spinner);
29 | ArrayAdapter adapter = ArrayAdapter.createFromResource(this,
30 | R.array.conversion_type_array, android.R.layout.simple_spinner_item);
31 | adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
32 | spinner.setAdapter(adapter);
33 |
34 | spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
35 | @Override
36 | public void onItemSelected(AdapterView> parent, View view, int position, long id) {
37 | switch (position) {
38 | case 0:
39 | currentConversionType = ConversionType.TW2SP;
40 | break;
41 | case 1:
42 | currentConversionType = ConversionType.S2HK;
43 | break;
44 | case 2:
45 | currentConversionType = ConversionType.S2T;
46 | break;
47 | case 3:
48 | currentConversionType = ConversionType.S2TW;
49 | break;
50 | case 4:
51 | currentConversionType = ConversionType.S2TWP;
52 | break;
53 | case 5:
54 | currentConversionType = ConversionType.T2HK;
55 | break;
56 | case 6:
57 | currentConversionType = ConversionType.T2S;
58 | break;
59 | case 7:
60 | currentConversionType = ConversionType.T2TW;
61 | break;
62 | case 8:
63 | currentConversionType = ConversionType.TW2S;
64 | break;
65 | case 9:
66 | currentConversionType = ConversionType.HK2S;
67 | break;
68 | }
69 | }
70 |
71 | @Override
72 | public void onNothingSelected(AdapterView> parent) {
73 |
74 | }
75 | });
76 |
77 | final EditText textView = findViewById(R.id.text);
78 |
79 | findViewById(R.id.btn).setOnClickListener(v -> {
80 | String originalText = textView.getText().toString();
81 | Runnable runnable = () -> {
82 | final String converted = ChineseConverter.convert(originalText,
83 | currentConversionType, getApplicationContext());
84 | textView.post(() -> textView.setText(converted));
85 | };
86 | executorService.execute(runnable);
87 | });
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
16 |
17 |
24 |
25 |
31 |
32 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Android-OpenCC
3 | 滑鼠裡面的矽二極體壞了,導致游標解析度降低\n我們在寮國的伺服器的硬碟需要使用網際網路演算法軟體解決非同步的問題。
4 |
5 | - 臺灣正體到簡體,並轉爲大陸常用詞彙
6 | - 簡體到香港繁體
7 | - 簡體到繁體
8 | - 簡體到臺灣正體
9 | - 簡體到繁體,並轉換爲臺灣常用詞彙
10 | - 繁體到香港繁體
11 | - 繁體到簡體
12 | - 繁體臺灣正體
13 | - 臺灣正體到簡體
14 | - 香港繁體到簡體
15 |
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | google()
6 | mavenCentral()
7 | }
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:4.2.1'
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | mavenCentral()
19 | maven { url 'https://jitpack.io' }
20 | }
21 | }
22 |
23 | task clean(type: Delete) {
24 | delete rootProject.buildDir
25 | }
26 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | bintrayRepo = 'maven'
20 | bintrayName = 'lib-opencc-android'
21 | publishedGroupId = 'com.zqc.opencc.android.lib'
22 | libraryName = 'lib-opencc-android'
23 | artifact = 'lib-opencc-android'
24 | libraryDescription = 'An Android library project for conversion between Traditional and Simplified Chinese'
25 | siteUrl = 'https://github.com/qichuan/android-opencc'
26 | gitUrl = 'https://github.com/qichuan/android-opencc.git'
27 | libraryVersion = '1.2.0'
28 | developerId = 'qichuan'
29 | developerName = 'Zhang Qichuan'
30 | developerEmail = 'qichuan@zhangqichuan.com'
31 | licenseName = 'MIT License'
32 | licenseUrl = 'https://opensource.org/licenses/MIT'
33 | allLicenses = ["MIT License"]
34 | android.useAndroidX=true
35 | android.enableJetifier=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed May 19 20:57:01 SGT 2021
2 | distributionBase=GRADLE_USER_HOME
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip
4 | distributionPath=wrapper/dists
5 | zipStorePath=wrapper/dists
6 | zipStoreBase=GRADLE_USER_HOME
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/lib-opencc-android/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/lib-opencc-android/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | android {
3 | compileSdkVersion = 30
4 | buildToolsVersion = "30.0.3"
5 | ndkVersion "21.1.6352462"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 30
10 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
11 | }
12 | externalNativeBuild {
13 | ndkBuild {
14 | path 'src/main/jni/Android.mk'
15 | }
16 | }
17 |
18 | dependencies {
19 | androidTestImplementation('junit:junit:4.13.2')
20 | androidTestImplementation 'androidx.test.ext:junit:1.1.2'
21 | androidTestImplementation('androidx.test:core:1.3.0')
22 | androidTestImplementation('androidx.test:runner:1.3.0')
23 | androidTestImplementation('androidx.test:rules:1.3.0')
24 | }
25 | }
--------------------------------------------------------------------------------
/lib-opencc-android/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /Users/zhangqichuan/dev/android-sdk-macosx/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/androidTest/java/com/zqc/opencc/andorid/lib/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.zqc.opencc.andorid.lib;
2 |
3 | import android.content.Context;
4 |
5 | import androidx.test.core.app.ApplicationProvider;
6 | import androidx.test.ext.junit.runners.AndroidJUnit4;
7 |
8 | import com.zqc.opencc.android.lib.ChineseConverter;
9 | import com.zqc.opencc.android.lib.ConversionType;
10 |
11 | import org.junit.After;
12 | import org.junit.Assert;
13 | import org.junit.Before;
14 | import org.junit.Test;
15 | import org.junit.runner.RunWith;
16 |
17 | /**
18 | * Created by zhangqichuan on 7/3/16.
19 | */
20 | @RunWith(AndroidJUnit4.class)
21 | public class ApplicationTest {
22 |
23 | private Context context;
24 |
25 | @Before
26 | public void setUp() {
27 | context = ApplicationProvider.getApplicationContext();
28 | }
29 |
30 | @After
31 | public void tearDown() {
32 | ChineseConverter.clearDictDataFolder(context);
33 | }
34 |
35 | @Test
36 | public void testHK2S() {
37 | baseTest("虛偽歎息\n" +
38 | "潮濕灶台\n" +
39 | "沙河涌洶湧的波浪",
40 |
41 | "虚伪叹息\n" +
42 | "潮湿灶台\n" +
43 | "沙河涌汹涌的波浪", ConversionType.HK2S);
44 | }
45 |
46 | @Test
47 | public void testHK2T() {
48 | baseTest("揾到食\n" + "偽裝者",
49 | "搵到食\n" + "僞裝者", ConversionType.HK2T);
50 | }
51 |
52 | @Test
53 | public void testJP2T() {
54 | baseTest("七歳\n" + "漢字",
55 | "七歲\n" + "漢字", ConversionType.JP2T);
56 | }
57 |
58 | @Test
59 | public void testS2HK() {
60 | baseTest("虚伪叹息\n" +
61 | "潮湿灶台\n" +
62 | "沙河涌汹涌的波浪",
63 |
64 | "虛偽嘆息\n" +
65 | "潮濕灶台\n" +
66 | "沙河涌洶湧的波浪", ConversionType.S2HK);
67 | }
68 |
69 | @Test
70 | public void testS2T() {
71 | baseTest("夸夸其谈 夸父逐日\n" +
72 | "我干什么不干你事。\n" +
73 | "太后的头发很干燥。\n" +
74 | "燕燕于飞,差池其羽。之子于归,远送于野。\n" +
75 | "请成相,世之殃,愚暗愚暗堕贤良。人主无贤,如瞽无相何伥伥!请布基,慎圣人,愚而自专事不治。主忌苟胜,群臣莫谏必逢灾。\n" +
76 | "曾经有一份真诚的爱情放在我面前,我没有珍惜,等我失去的时候我才后悔莫及。人事间最痛苦的事莫过于此。如果上天能够给我一个再来一次得机会,我会对那个女孩子说三个字,我爱你。如果非要在这份爱上加个期限,我希望是,一万年。\n" +
77 | "新的理论被发现了。\n" +
78 | "鲶鱼和鲇鱼是一种生物。\n" +
79 | "金胄不是金色的甲胄。",
80 |
81 | "誇誇其談 夸父逐日\n" +
82 | "我幹什麼不干你事。\n" +
83 | "太后的頭髮很乾燥。\n" +
84 | "燕燕于飛,差池其羽。之子于歸,遠送於野。\n" +
85 | "請成相,世之殃,愚闇愚闇墮賢良。人主無賢,如瞽無相何倀倀!請布基,慎聖人,愚而自專事不治。主忌苟勝,羣臣莫諫必逢災。\n" +
86 | "曾經有一份真誠的愛情放在我面前,我沒有珍惜,等我失去的時候我才後悔莫及。人事間最痛苦的事莫過於此。如果上天能夠給我一個再來一次得機會,我會對那個女孩子說三個字,我愛你。如果非要在這份愛上加個期限,我希望是,一萬年。\n" +
87 | "新的理論被發現了。\n" +
88 | "鯰魚和鮎魚是一種生物。\n" +
89 | "金胄不是金色的甲冑。", ConversionType.S2T);
90 | }
91 |
92 | @Test
93 | public void testS2TW() {
94 | baseTest("着装污染虚伪发泄棱柱群众里面\n" +
95 | "鲶鱼和鲇鱼是一种生物。",
96 |
97 | "著裝汙染虛偽發洩稜柱群眾裡面\n" +
98 | "鯰魚和鯰魚是一種生物。", ConversionType.S2TW);
99 | }
100 |
101 | @Test
102 | public void testS2TWP() {
103 | baseTest("鼠标里面的硅二极管坏了,导致光标分辨率降低。\n" +
104 | "我们在老挝的服务器的硬盘需要使用互联网算法软件解决异步的问题。\n" +
105 | "为什么你在床里面睡着?",
106 |
107 | "滑鼠裡面的矽二極體壞了,導致游標解析度降低。\n" +
108 | "我們在寮國的伺服器的硬碟需要使用網際網路演算法軟體解決非同步的問題。\n" +
109 | "為什麼你在床裡面睡著?", ConversionType.S2TWP);
110 | }
111 |
112 | @Test
113 | public void testT2S() {
114 | baseTest("曾經有一份真誠的愛情放在我面前,我沒有珍惜,等我失去的時候我才後悔莫及。人事間最痛苦的事莫過於此。如果上天能夠給我一個再來一次得機會,我會對那個女孩子說三個字,我愛你。如果非要在這份愛上加個期限,我希望是,一萬年。",
115 |
116 | "曾经有一份真诚的爱情放在我面前,我没有珍惜,等我失去的时候我才后悔莫及。人事间最痛苦的事莫过于此。如果上天能够给我一个再来一次得机会,我会对那个女孩子说三个字,我爱你。如果非要在这份爱上加个期限,我希望是,一万年。",
117 | ConversionType.T2S);
118 | }
119 |
120 | @Test
121 | public void testTW2S() {
122 | baseTest("著裝著作汙染虛偽發洩稜柱群眾裡面",
123 |
124 | "着装著作污染虚伪发泄棱柱群众里面", ConversionType.TW2S);
125 | }
126 |
127 | @Test
128 | public void testTW2SP() {
129 | baseTest("滑鼠裡面的矽二極體壞了,導致游標解析度降低。\n" +
130 | "我們在寮國的伺服器的硬碟需要使用網際網路演算法軟體解決非同步的問題。\n" +
131 | "為什麼你在床裡面睡著?",
132 |
133 | "鼠标里面的硅二极管坏了,导致光标分辨率降低。\n" +
134 | "我们在老挝的服务器的硬盘需要使用互联网算法软件解决异步的问题。\n" +
135 | "为什么你在床里面睡着?",
136 | ConversionType.TW2SP);
137 | }
138 |
139 | @Test
140 | public void testT2JP() {
141 | baseTest("七歲\n" + "漢字",
142 | "七歳\n" + "漢字", ConversionType.T2JP);
143 | }
144 |
145 | @Test
146 | public void testTW2T() {
147 | baseTest("正體字\n",
148 | "正體字\n", ConversionType.TW2T);
149 | }
150 |
151 | private void baseTest(String originalText, String expectedText, ConversionType conversionType) {
152 | Assert.assertEquals(expectedText, ChineseConverter.convert(originalText, conversionType, context));
153 | }
154 | }
155 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/HKVariants.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/HKVariants.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/HKVariantsRev.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/HKVariantsRev.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/HKVariantsRevPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/HKVariantsRevPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/JPShinjitaiCharacters.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/JPShinjitaiCharacters.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/JPShinjitaiPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/JPShinjitaiPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/JPVariants.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/JPVariants.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/JPVariantsRev.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/JPVariantsRev.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/STCharacters.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/STCharacters.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/STPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/STPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TSCharacters.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TSCharacters.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TSPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TSPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TWPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TWPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TWPhrasesRev.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TWPhrasesRev.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TWVariants.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TWVariants.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TWVariantsRev.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TWVariantsRev.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/TWVariantsRevPhrases.ocd2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/TWVariantsRevPhrases.ocd2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/hk2s.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese (Hong Kong variant) to Simplified Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TSPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "HKVariantsRevPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "HKVariantsRev.ocd2"
19 | }]
20 | }
21 | }, {
22 | "dict": {
23 | "type": "group",
24 | "dicts": [{
25 | "type": "ocd2",
26 | "file": "TSPhrases.ocd2"
27 | }, {
28 | "type": "ocd2",
29 | "file": "TSCharacters.ocd2"
30 | }]
31 | }
32 | }]
33 | }
34 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/hk2t.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "HKVariantsRevPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "HKVariantsRevPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "HKVariantsRev.ocd2"
19 | }]
20 | }
21 | }]
22 | }
23 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/jp2t.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "JPShinjitaiPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "JPShinjitaiPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "JPShinjitaiCharacters.ocd2"
19 | }, {
20 | "type": "ocd2",
21 | "file": "JPVariantsRev.ocd2"
22 | }]
23 | }
24 | }]
25 | }
26 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/s2hk.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simplified Chinese to Traditional Chinese (Hong Kong variant)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "STPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "STPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "STCharacters.ocd2"
19 | }]
20 | }
21 | }, {
22 | "dict": {
23 | "type": "ocd2",
24 | "file": "HKVariants.ocd2"
25 | }
26 | }]
27 | }
28 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/s2t.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simplified Chinese to Traditional Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "STPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "STPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "STCharacters.ocd2"
19 | }]
20 | }
21 | }]
22 | }
23 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/s2tw.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "STPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "STPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "STCharacters.ocd2"
19 | }]
20 | }
21 | }, {
22 | "dict": {
23 | "type": "ocd2",
24 | "file": "TWVariants.ocd2"
25 | }
26 | }]
27 | }
28 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/s2twp.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "STPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "STPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "STCharacters.ocd2"
19 | }]
20 | }
21 | }, {
22 | "dict": {
23 | "type": "ocd2",
24 | "file": "TWPhrases.ocd2"
25 | }
26 | }, {
27 | "dict": {
28 | "type": "ocd2",
29 | "file": "TWVariants.ocd2"
30 | }
31 | }]
32 | }
33 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/t2hk.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese to Traditional Chinese (Hong Kong variant)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "HKVariants.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "ocd2",
13 | "file": "HKVariants.ocd2"
14 | }
15 | }]
16 | }
17 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/t2jp.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "JPVariants.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "ocd2",
13 | "file": "JPVariants.ocd2"
14 | }
15 | }]
16 | }
17 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/t2s.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese to Simplified Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TSPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "TSPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "TSCharacters.ocd2"
19 | }]
20 | }
21 | }]
22 | }
23 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/t2tw.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese to Traditional Chinese (Taiwan standard)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TWVariants.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "ocd2",
13 | "file": "TWVariants.ocd2"
14 | }
15 | }]
16 | }
17 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/tw2s.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TSPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "TWVariantsRevPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "TWVariantsRev.ocd2"
19 | }]
20 | }
21 | }, {
22 | "dict": {
23 | "type": "group",
24 | "dicts": [{
25 | "type": "ocd2",
26 | "file": "TSPhrases.ocd2"
27 | }, {
28 | "type": "ocd2",
29 | "file": "TSCharacters.ocd2"
30 | }]
31 | }
32 | }]
33 | }
34 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/tw2sp.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TSPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "TWPhrasesRev.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "TWVariantsRevPhrases.ocd2"
19 | }, {
20 | "type": "ocd2",
21 | "file": "TWVariantsRev.ocd2"
22 | }]
23 | }
24 | }, {
25 | "dict": {
26 | "type": "group",
27 | "dicts": [{
28 | "type": "ocd2",
29 | "file": "TSPhrases.ocd2"
30 | }, {
31 | "type": "ocd2",
32 | "file": "TSCharacters.ocd2"
33 | }]
34 | }
35 | }]
36 | }
37 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/tw2t.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Traditional Chinese (Taiwan standard) to Traditional Chinese",
3 | "segmentation": {
4 | "type": "mmseg",
5 | "dict": {
6 | "type": "ocd2",
7 | "file": "TWVariantsRevPhrases.ocd2"
8 | }
9 | },
10 | "conversion_chain": [{
11 | "dict": {
12 | "type": "group",
13 | "dicts": [{
14 | "type": "ocd2",
15 | "file": "TWVariantsRevPhrases.ocd2"
16 | }, {
17 | "type": "ocd2",
18 | "file": "TWVariantsRev.ocd2"
19 | }]
20 | }
21 | }]
22 | }
23 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/assets/openccdata/zFinished2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/qichuan/android-opencc/96002915bb4c58d0d4e92a939e2879f21bd62134/lib-opencc-android/src/main/assets/openccdata/zFinished2
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/java/com/zqc/opencc/android/lib/ChineseConverter.java:
--------------------------------------------------------------------------------
1 | package com.zqc.opencc.android.lib;
2 |
3 | import android.content.Context;
4 | import android.content.res.AssetManager;
5 | import android.util.Log;
6 |
7 | import java.io.File;
8 | import java.io.FileOutputStream;
9 | import java.io.IOException;
10 | import java.io.InputStream;
11 | import java.io.OutputStream;
12 |
13 | /**
14 | * Created by zhangqichuan on 29/2/16.
15 | */
16 | public class ChineseConverter {
17 |
18 | /***
19 | * @param text the text to be converted to
20 | * @param conversionType the conversion type
21 | * @param context android context
22 | * @return the converted text
23 | */
24 | public static String convert(String text, ConversionType conversionType, Context context) {
25 | File lastDataFile = new File(context.getFilesDir() + "/openccdata/zFinished2");
26 | if (!lastDataFile.exists()) {
27 | initialize(context);
28 | }
29 | File dataFolder = new File(context.getFilesDir() + "/openccdata");
30 | return convert(text, conversionType.getValue(), dataFolder.getAbsolutePath());
31 | }
32 |
33 | /***
34 | * Clear the dictionary data folder, only call this method when update the dictionary data.
35 | * @param context
36 | */
37 | public static void clearDictDataFolder(Context context){
38 | File dataFolder = new File(context.getFilesDir() + "/openccdata");
39 | deleteRecursive(dataFolder);
40 | }
41 |
42 | private static void deleteRecursive(File fileOrDirectory) {
43 | if (fileOrDirectory.isDirectory())
44 | for (File child : fileOrDirectory.listFiles())
45 | deleteRecursive(child);
46 |
47 | fileOrDirectory.delete();
48 | }
49 |
50 | private static native String convert(String text, String configFile, String absoluteDataFolderPath);
51 |
52 | private static void initialize(Context context) {
53 | copyFolder("openccdata", context);
54 | }
55 |
56 | private static void copyFolder(String folderName, Context context) {
57 | File fileFolderOnDisk = new File(context.getFilesDir() + "/" + folderName);
58 | AssetManager assetManager = context.getAssets();
59 | String[] files = null;
60 | try {
61 | files = assetManager.list(folderName);
62 | } catch (IOException e) {
63 | Log.e("tag", "Failed to get asset file list.", e);
64 | }
65 | if (files != null) {
66 | for (String filename : files) {
67 | InputStream in = null;
68 | OutputStream out = null;
69 | try {
70 | in = assetManager.open(folderName + "/" + filename);
71 | if (!fileFolderOnDisk.exists()) {
72 | fileFolderOnDisk.mkdirs();
73 | }
74 | File outFile = new File(fileFolderOnDisk.getAbsolutePath(), filename);
75 | if (!outFile.exists()) {
76 | outFile.createNewFile();
77 | }
78 | out = new FileOutputStream(outFile);
79 | copyFile(in, out);
80 | } catch (IOException e) {
81 | Log.e("tag", "Failed to copy asset file: " + filename, e);
82 | } finally {
83 | if (in != null) {
84 | try {
85 | in.close();
86 | } catch (IOException e) {
87 | // NOOP
88 | }
89 | }
90 | if (out != null) {
91 | try {
92 | out.close();
93 | } catch (IOException e) {
94 | // NOOP
95 | }
96 | }
97 | }
98 | }
99 | }
100 | }
101 |
102 |
103 | private static void copyFile(InputStream in, OutputStream out) throws IOException {
104 | byte[] buffer = new byte[1024];
105 | int read;
106 | while ((read = in.read(buffer)) != -1) {
107 | out.write(buffer, 0, read);
108 | }
109 | }
110 |
111 | static {
112 | System.loadLibrary("ChineseConverter");
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/java/com/zqc/opencc/android/lib/ConversionType.java:
--------------------------------------------------------------------------------
1 | package com.zqc.opencc.android.lib;
2 |
3 | /**
4 | * Created by zhangqichuan on 2/3/16.
5 | */
6 | public enum ConversionType {
7 | HK2S, //hk2s.json Traditional Chinese (Hong Kong Standard) to Simplified Chinese 香港繁體(香港小學學習字詞表標準)到簡體
8 | HK2T, //hk2t.json Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁體(香港小學學習字詞表標準)到繁體
9 | JP2T, //jp2t.json New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日本漢字到繁體
10 | S2HK, //s2hk.json Simplified Chinese to Traditional Chinese (Hong Kong Standard) 簡體到香港繁體(香港小學學習字詞表標準)
11 | S2T, //s2t.json Simplified Chinese to Traditional Chinese 簡體到繁體
12 | S2TW,//s2tw.json Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體
13 | S2TWP, //s2twp.json Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
14 | T2HK, //t2hk.json Traditional Chinese to Traditional Chinese (Hong Kong Standard) 繁體到香港繁體(香港小學學習字詞表標準)
15 | T2S, //t2s.json Traditional Chinese to Simplified Chinese 繁體到簡體
16 | T2TW,//t2tw.json Traditional Chinese to Traditional Chinese (Taiwan Standard) 繁體臺灣正體
17 | T2JP, //t2jp.json Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁體到日本漢字
18 | TW2S, //tw2s.json Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體
19 | TW2T, //tw2t.json Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體
20 | TW2SP; //tw2sp.json Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙
21 |
22 | public String getValue() {
23 | if (this == HK2S) {
24 | return "hk2s.json";
25 | } else if (this == HK2T){
26 | return "hk2t.json";
27 | } else if (this == JP2T){
28 | return "jp2t.json";
29 | } else if (this == S2HK) {
30 | return "s2hk.json";
31 | } else if (this == S2T) {
32 | return "s2t.json";
33 | } else if (this == S2TW) {
34 | return "s2tw.json";
35 | } else if (this == S2TWP) {
36 | return "s2twp.json";
37 | } else if (this == T2HK) {
38 | return "t2hk.json";
39 | } else if (this == T2S) {
40 | return "t2s.json";
41 | } else if (this == T2TW) {
42 | return "t2tw.json";
43 | } else if (this == T2JP) {
44 | return "t2jp.json";
45 | } else if (this == TW2S) {
46 | return "tw2s.json";
47 | } else if (this == TW2T) {
48 | return "tw2t.json";
49 | } else if (this == TW2SP) {
50 | return "tw2sp.json";
51 | }
52 | return "s2t.json";
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/jni/Android.mk:
--------------------------------------------------------------------------------
1 | LOCAL_PATH := $(call my-dir)
2 | include $(CLEAR_VARS)
3 |
4 | LOCAL_CFLAGS := -DOPENCC_ENABLE_DARTS
5 |
6 | LOCAL_MODULE := OpenCC
7 | LOCAL_C_INCLUDES += src/main/jni/OpenCC/deps/darts-clone/
8 | LOCAL_C_INCLUDES += src/main/jni/OpenCC/deps/marisa-0.2.6/include/
9 | LOCAL_C_INCLUDES += src/main/jni/OpenCC/deps/marisa-0.2.6/lib/
10 | LOCAL_C_INCLUDES += src/main/jni/OpenCC/deps/rapidjson-1.1.0/
11 |
12 | LOCAL_SRC_FILES := \
13 | OpenCC/src/BinaryDict.cpp \
14 | OpenCC/src/Config.cpp \
15 | OpenCC/src/Conversion.cpp\
16 | OpenCC/src/ConversionChain.cpp \
17 | OpenCC/src/Converter.cpp \
18 | OpenCC/src/DartsDict.cpp \
19 | OpenCC/src/Dict.cpp \
20 | OpenCC/src/DictEntry.cpp \
21 | OpenCC/src/DictGroup.cpp \
22 | OpenCC/src/Lexicon.cpp \
23 | OpenCC/src/MarisaDict.cpp \
24 | OpenCC/src/MaxMatchSegmentation.cpp \
25 | OpenCC/src/PhraseExtract.cpp \
26 | OpenCC/src/SerializedValues.cpp \
27 | OpenCC/src/Segmentation.cpp \
28 | OpenCC/src/SimpleConverter.cpp \
29 | OpenCC/src/TextDict.cpp \
30 | OpenCC/src/UTF8StringSlice.cpp \
31 | OpenCC/src/UTF8Util.cpp \
32 | OpenCC/deps/marisa-0.2.6/lib/marisa/trie.cc \
33 | OpenCC/deps/marisa-0.2.6/lib/marisa/agent.cc \
34 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/io/reader.cc \
35 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/io/writer.cc \
36 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/io/mapper.cc \
37 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/trie/louds-trie.cc \
38 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/trie/tail.cc \
39 | OpenCC/deps/marisa-0.2.6/lib/marisa/grimoire/vector/bit-vector.cc \
40 | OpenCC/deps/marisa-0.2.6/lib/marisa/keyset.cc
41 |
42 | include $(BUILD_STATIC_LIBRARY)
43 |
44 | include $(CLEAR_VARS)
45 | LOCAL_PRELINK_MODULE := false
46 |
47 | LOCAL_MODULE := ChineseConverter
48 | LOCAL_C_INCLUDES += src/main/jni/OpenCC/src/
49 | LOCAL_STATIC_LIBRARIES := OpenCC
50 | LOCAL_LDLIBS += -llog -landroid
51 |
52 | LOCAL_SRC_FILES := chineseconverter.cpp
53 |
54 | include $(BUILD_SHARED_LIBRARY)
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/jni/Application.mk:
--------------------------------------------------------------------------------
1 | APP_ABI := all
2 | APP_STL := c++_static
3 | APP_CPPFLAGS := -fexceptions
--------------------------------------------------------------------------------
/lib-opencc-android/src/main/jni/chineseconverter.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include "Converter.hpp"
4 | #include "Config.hpp"
5 |
6 | extern "C"
7 | jstring
8 | Java_com_zqc_opencc_android_lib_ChineseConverter_convert(
9 | JNIEnv *env, jclass type, jstring text_, jstring configFile_, jstring absoluteDataFolderPath_) {
10 | const char *text = env->GetStringUTFChars(text_, 0);
11 | const char *configFile = env->GetStringUTFChars(configFile_, 0);
12 | const char *absoluteDataFolderPath = env->GetStringUTFChars(absoluteDataFolderPath_, 0);
13 |
14 | opencc::Config config;
15 | opencc::ConverterPtr converter = config.NewFromFile(std::string(absoluteDataFolderPath) + "/" + std::string(configFile));
16 |
17 | env->ReleaseStringUTFChars(text_, text);
18 | env->ReleaseStringUTFChars(configFile_, configFile);
19 | env->ReleaseStringUTFChars(absoluteDataFolderPath_, absoluteDataFolderPath);
20 |
21 | return env->NewStringUTF(converter->Convert(text).c_str());
22 | }
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':lib-opencc-android'
2 | include ':app'
3 |
--------------------------------------------------------------------------------