From cd7954c32f87bf48d7f8a83aaba4cee16dd630dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Wed, 7 Dec 2016 16:37:48 +0800 Subject: [PATCH] Localized the error message. --- PokemonGoIV/0Main.vb | 3 ++- PokemonGoIV/8Registry.vb | 22 ++++++++++++++++++---- TODO | 1 - oxt/PokemonGoIV/0Main.xba | 3 ++- oxt/PokemonGoIV/8Registry.xba | 22 ++++++++++++++++++---- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/PokemonGoIV/0Main.vb b/PokemonGoIV/0Main.vb index 258f3b3..a923ffc 100644 --- a/PokemonGoIV/0Main.vb +++ b/PokemonGoIV/0Main.vb @@ -70,7 +70,8 @@ Sub subMain End If maIVs = fnFindIV (aQuery) If UBound (maIVs) = -1 Then - MsgBox "Found no matching IV." + 'MsgBox "Found no matching IV." + MsgBox fnGetResString ("msg1000") Else subSaveIV (aQuery, maIVs) End If diff --git a/PokemonGoIV/8Registry.vb b/PokemonGoIV/8Registry.vb index 0ee9ffe..d5ab408 100644 --- a/PokemonGoIV/8Registry.vb +++ b/PokemonGoIV/8Registry.vb @@ -8,11 +8,19 @@ Const BASE_KEY As String = "/org.openoffice.Office.Addons.PokemonGoIV.AddonConfi ' fnGetImageUrl: Returns the image URL for the UNO image controls. Function fnGetImageUrl (sName As String) As String Dim oRegKey As Object - + oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName) fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url) End Function +' fnGetResString: Returns the localized text string. +Function fnGetResString (sID As String) As String + Dim oRegKey As Object + + oRegKey = fnGetRegistryKeyContent (BASE_KEY & "Messages/" & sID) + fnGetResString = oRegKey.Text +End Function + ' fnGetRegistryKeyContent: Returns the registry key content Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean) Dim oConfigProvider As Object @@ -23,12 +31,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo aNodePath(0).Name = "nodepath" aNodePath(0).Value = sKeyName If IsMissing (bForUpdate) Then - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationAccess", _ + aNodePath()) Else If bForUpdate Then - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationUpdateAccess", _ + aNodePath()) Else - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationAccess", _ + aNodePath()) End If End If End Function diff --git a/TODO b/TODO index 1a628ca..faf9413 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,4 @@ PokemonGoIV TODO -* Error messages. * Show images of teams, team leaders and Pokémons. * Center the dialog. diff --git a/oxt/PokemonGoIV/0Main.xba b/oxt/PokemonGoIV/0Main.xba index d9b7e0b..ed6d3cc 100644 --- a/oxt/PokemonGoIV/0Main.xba +++ b/oxt/PokemonGoIV/0Main.xba @@ -72,7 +72,8 @@ Sub subMain End If maIVs = fnFindIV (aQuery) If UBound (maIVs) = -1 Then - MsgBox "Found no matching IV." + 'MsgBox "Found no matching IV." + MsgBox fnGetResString ("msg1000") Else subSaveIV (aQuery, maIVs) End If diff --git a/oxt/PokemonGoIV/8Registry.xba b/oxt/PokemonGoIV/8Registry.xba index ab34638..e0b88dc 100644 --- a/oxt/PokemonGoIV/8Registry.xba +++ b/oxt/PokemonGoIV/8Registry.xba @@ -10,11 +10,19 @@ Const BASE_KEY As String = "/org.openoffice.Office.Addons.PokemonGoIV.Addon ' fnGetImageUrl: Returns the image URL for the UNO image controls. Function fnGetImageUrl (sName As String) As String Dim oRegKey As Object - + oRegKey = fnGetRegistryKeyContent (BASE_KEY & "FileResources/" & sName) fnGetImageUrl = fnExpandMacroFieldExpression (oRegKey.Url) End Function +' fnGetResString: Returns the localized text string. +Function fnGetResString (sID As String) As String + Dim oRegKey As Object + + oRegKey = fnGetRegistryKeyContent (BASE_KEY & "Messages/" & sID) + fnGetResString = oRegKey.Text +End Function + ' fnGetRegistryKeyContent: Returns the registry key content Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boolean) Dim oConfigProvider As Object @@ -25,12 +33,18 @@ Function fnGetRegistryKeyContent (sKeyName as string, Optional bforUpdate as Boo aNodePath(0).Name = "nodepath" aNodePath(0).Value = sKeyName If IsMissing (bForUpdate) Then - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationAccess", _ + aNodePath()) Else If bForUpdate Then - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationUpdateAccess", _ + aNodePath()) Else - fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ("com.sun.star.configuration.ConfigurationAccess", aNodePath()) + fnGetRegistryKeyContent = oConfigProvider.createInstanceWithArguments ( _ + "com.sun.star.configuration.ConfigurationAccess", _ + aNodePath()) End If End If End Function