Skip to content
Browse files

Add possibility to search in French without accent.

  • Loading branch information...
1 parent a1022d8 commit 2c731c3194452da74d5be47ee5a3d0515187d3dd @Nilhcem committed Mar 9, 2012
View
8 res/values-fr/strings.xml
@@ -6,8 +6,8 @@
<!-- Import data -->
<string name="import_service_label">Import / Mise à jour des données</string>
<string name="import_welcome_title">Bienvenue</string>
- <string name="import_welcome_msg">Les données de l\'application ont besoin d\'être téléchargées.\nVotre appareil doit être connecté à Internet.\n5 MO vont être téléchargés et environ 15 MO seront nécessaires pendant le processus d\'installation.\n\nVoulez-vous commencer le téléchargement maintenant ?</string>
- <string name="import_processing_msg">Téléchargement des données du dictionnaire (5M).\nVeuillez patienter…</string>
+ <string name="import_welcome_msg">Les données de l\'application ont besoin d\'être téléchargées.\nVotre appareil doit être connecté à Internet.\n5,5 MO vont être téléchargés et environ 20 MO seront nécessaires pendant le processus d\'installation.\n\nVoulez-vous commencer le téléchargement maintenant ?</string>
+ <string name="import_processing_msg">Téléchargement des données du dictionnaire (5,5M).\nVeuillez patienter…</string>
<string name="import_start_service_btn">Télécharger</string>
<string name="import_quit_activity_btn">Quitter</string>
<string name="import_done">Terminé</string>
@@ -36,8 +36,8 @@
<!-- Update data -->
<string name="update_service_label">Vérification des mises à jour</string>
<string name="update_welcome_title">Mise à jour du dictionnaire</string>
- <string name="update_welcome_msg">Une mise à jour du dictionnaire est disponible.\nVeuillez vous assurer que le périphérique est bien connecté à Internet.\n5 MO vont être téléchargés et environ 15 MO seront nécessaires pendant le processus d\'installation.\n\nVoulez-vous commencer la mise à jour maintenant ?</string>
- <string name="update_processing_msg">Mise à jour du dictionnaire (5M).\nVeuillez patienter…</string>
+ <string name="update_welcome_msg">Une mise à jour du dictionnaire est disponible.\nVeuillez vous assurer que le périphérique est bien connecté à Internet.\n5,5 MO vont être téléchargés et environ 20 MO seront nécessaires pendant le processus d\'installation.\n\nVoulez-vous commencer la mise à jour maintenant ?</string>
+ <string name="update_processing_msg">Mise à jour du dictionnaire (5,5M).\nVeuillez patienter…</string>
<string name="update_start_service_btn">Mettre à jour</string>
<string name="update_quit_activity_btn">Annuler</string>
<string name="update_dialog_msg">Le dictionnaire a été mis à jour avec succès !\nMerci d\'avoir patienté.</string>
View
8 res/values-zh-rCN/strings.xml
@@ -6,8 +6,8 @@
<!-- Import data -->
<string name="import_service_label">词典导入/更新</string>
<string name="import_welcome_title">欢迎使用</string>
- <string name="import_welcome_msg">首先请下载本词典.\n同时确保您的设备已联网.\n它将占用5MB的空间,此安装过程需要15MB的空间.\n\n立即下载?</string>
- <string name="import_processing_msg">正在下载词典数据(5M).\n请稍候…</string>
+ <string name="import_welcome_msg">首先请下载本词典.\n同时确保您的设备已联网.\n它将占用5.5MB的空间,此安装过程需要20MB的空间.\n\n立即下载?</string>
+ <string name="import_processing_msg">正在下载词典数据(5.5M).\n请稍候…</string>
<string name="import_start_service_btn">下载</string>
<string name="import_quit_activity_btn">退出</string>
<string name="import_done">完成</string>
@@ -36,8 +36,8 @@
<!-- Update data -->
<string name="update_service_label">查看更新</string>
<string name="update_welcome_title">更新词典</string>
- <string name="update_welcome_msg">词典更新可用.\n请确保您的设备已联网.\n它将占用5MB的空间,此安装过程需要15MB的空间.\n\n立即下载?</string>
- <string name="update_processing_msg">正在更新数据(5M).\n请稍候…</string>
+ <string name="update_welcome_msg">词典更新可用.\n请确保您的设备已联网.\n它将占用5.5MB的空间,此安装过程需要20MB的空间.\n\n立即下载?</string>
+ <string name="update_processing_msg">正在更新数据(5.5M).\n请稍候…</string>
<string name="update_start_service_btn">更新</string>
<string name="update_quit_activity_btn">取消</string>
<string name="update_dialog_msg">词典更新成功!\n感谢您的耐心等候.</string>
View
8 res/values-zh/strings.xml
@@ -6,8 +6,8 @@
<!-- Import data -->
<string name="import_service_label">詞典導入/更新</string>
<string name="import_welcome_title">歡迎使用</string>
- <string name="import_welcome_msg">首先请下载本词典.\n同時確保您的設備已聯網.\n它將佔用5MB的空間,此安裝過程需要15MB的空間.\n\n立即下載?</string>
- <string name="import_processing_msg">正在下載詞典數據(5M).\n請稍候…</string>
+ <string name="import_welcome_msg">首先请下载本词典.\n同時確保您的設備已聯網.\n它將佔用5.5MB的空間,此安裝過程需要20MB的空間.\n\n立即下載?</string>
+ <string name="import_processing_msg">正在下載詞典數據(5.5M).\n請稍候…</string>
<string name="import_start_service_btn">下載</string>
<string name="import_quit_activity_btn">退出</string>
<string name="import_done">完成</string>
@@ -36,8 +36,8 @@
<!-- Update data -->
<string name="update_service_label">查看更新</string>
<string name="update_welcome_title">更新詞典</string>
- <string name="update_welcome_msg">詞典更新可用.\n請確保您的設備已聯網.\n它將佔用5MB的空間,此安裝過程需要15MB的空間.\n\n立即下載?</string>
- <string name="update_processing_msg">正在更新數據(5M).\n請稍候…</string>
+ <string name="update_welcome_msg">詞典更新可用.\n請確保您的設備已聯網.\n它將佔用5.5MB的空間,此安裝過程需要20MB的空間.\n\n立即下載?</string>
+ <string name="update_processing_msg">正在更新數據(5.5M).\n請稍候…</string>
<string name="update_start_service_btn">更新</string>
<string name="update_quit_activity_btn">取消</string>
<string name="update_dialog_msg">詞典更新成功!\n感謝您的耐心等候.</string>
View
8 res/values/strings.xml
@@ -6,8 +6,8 @@
<!-- Import data -->
<string name="import_service_label">Dictionary import / update</string>
<string name="import_welcome_title">Welcome</string>
- <string name="import_welcome_msg">The dictionary needs to be downloaded first.\nPlease make sure your device is connected to the Internet.\n5 MB will be downloaded and about 15 MB will be needed during the installation process.\n\nDo you want to start the download now?</string>
- <string name="import_processing_msg">Downloading dictionary data (5M).\nPlease wait…</string>
+ <string name="import_welcome_msg">The dictionary needs to be downloaded first.\nPlease make sure your device is connected to the Internet.\n5.5 MB will be downloaded and about 20 MB will be needed during the installation process.\n\nDo you want to start the download now?</string>
+ <string name="import_processing_msg">Downloading dictionary data (5.5M).\nPlease wait…</string>
<string name="import_start_service_btn">Download</string>
<string name="import_quit_activity_btn">Exit</string>
<string name="import_done">Done</string>
@@ -36,8 +36,8 @@
<!-- Update data -->
<string name="update_service_label">Check for updates</string>
<string name="update_welcome_title">Update dictionary</string>
- <string name="update_welcome_msg">A dictionary update is available.\nPlease make sure your device is connected to the Internet.\n5 MB will be downloaded and about 15 MB will be needed during the update process.\n\nDo you want to start the update now?</string>
- <string name="update_processing_msg">Updating dictionary data (5M).\nPlease wait…</string>
+ <string name="update_welcome_msg">A dictionary update is available.\nPlease make sure your device is connected to the Internet.\n5.5 MB will be downloaded and about 20 MB will be needed during the update process.\n\nDo you want to start the update now?</string>
+ <string name="update_processing_msg">Updating dictionary data (5.5M).\nPlease wait…</string>
<string name="update_start_service_btn">Update</string>
<string name="update_quit_activity_btn">Cancel</string>
<string name="update_dialog_msg">Dictionary has been successfully updated!\nThank you for your patience.</string>
View
19 src/com/nilhcem/frcndict/database/DatabaseHelper.java
@@ -4,6 +4,7 @@
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
+import java.util.regex.Pattern;
import android.content.ContentValues;
import android.database.Cursor;
@@ -28,9 +29,11 @@
private static final String QUERY_HANZI;
private static final String QUERY_PINYIN;
private static final String QUERY_FRENCH;
+ private static final String QUERY_FRENCH_NO_ACCENT;
private static final String QUERY_STARRED;
private final SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US);
+ private static final String REGEX_ACCENT = ".*[àâäçéèêëîïôöùûüæœÀÂÄÇÉÈÊËÎÏÔÖÙÛÜÆŒ].*";
static {
StringBuilder sb;
@@ -80,6 +83,7 @@
.append("` ASC LIMIT ?,")
.append(nbToDisplay);
QUERY_FRENCH = sb.toString();
+ QUERY_FRENCH_NO_ACCENT = QUERY_FRENCH.replaceAll(Tables.ENTRIES_KEY_TRANSLATION, Tables.ENTRIES_KEY_TRANS_NO_ACCENT);
// Starred query
sb = new StringBuilder(selectAll)
@@ -174,10 +178,17 @@ public Cursor searchPinyin(String search, Integer curPage) {
}
public Cursor searchFrench(String search, Integer curPage) {
- return mDb.rawQuery(DatabaseHelper.QUERY_FRENCH,
- new String[] {String.format("%%/%s%%", search),
- Integer.toString(SettingsActivity.NB_ENTRIES_PER_LIST * curPage)
- });
+ // Detect query (with or without accents)
+ String query;
+ if (Pattern.matches(DatabaseHelper.REGEX_ACCENT, search)) {
+ query = DatabaseHelper.QUERY_FRENCH;
+ } else {
+ query = DatabaseHelper.QUERY_FRENCH_NO_ACCENT;
+ }
+
+ return mDb.rawQuery(query, new String[] {String.format("%%/%s%%", search),
+ Integer.toString(SettingsActivity.NB_ENTRIES_PER_LIST * curPage)
+ });
}
public Cursor searchStarred(Integer curPage) {
View
1 src/com/nilhcem/frcndict/database/Tables.java
@@ -15,6 +15,7 @@
String ENTRIES_KEY_PINYIN = "pinyin";
String ENTRIES_KEY_PINYIN2 = "pinyin2";
String ENTRIES_KEY_TRANSLATION = "translation";
+ String ENTRIES_KEY_TRANS_NO_ACCENT = "trans_no_accent";
String ENTRIES_KEY_TRANS_AVG_LENGTH = "trans_avg_length";
String ENTRIES_KEY_STARRED_DATE = "starred_date";

0 comments on commit 2c731c3

Please sign in to comment.
Something went wrong with that request. Please try again.