You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2021/05/04 12:16:21 UTC
[lucenenet] 02/04: BREAKING:
Lucene.Net.QueryParsers.Flexible.Messages: Removed entire namespace,
as we have refactored to use .NET localization rather than NLS
This is an automated email from the ASF dual-hosted git repository.
nightowl888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit 60d1b82832b0b8696e31576de3698730deb0cc11
Author: Shad Storhaug <sh...@shadstorhaug.com>
AuthorDate: Sat May 1 06:32:57 2021 +0700
BREAKING: Lucene.Net.QueryParsers.Flexible.Messages: Removed entire namespace, as we have refactored to use .NET localization rather than NLS
---
.../Flexible/Messages/Message.cs | 65 +--
.../Flexible/Messages/MessageImpl.cs | 143 +++----
.../Flexible/Messages/NLS.cs | 449 +++++++++++----------
.../Flexible/Messages/NLSException.cs | 71 ++--
.../Flexible/Messages/MessagesTestBundle.cs | 81 ++--
.../Flexible/Messages/TestNLS.cs | 237 +++++------
6 files changed, 532 insertions(+), 514 deletions(-)
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
index fa9934d..e442f1c 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/Message.cs
@@ -1,33 +1,36 @@
-using System.Globalization;
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+//using System.Globalization;
- /// <summary>
- /// Message Interface for a lazy loading.
- /// For Native Language Support (NLS), system of software internationalization.
- /// </summary>
- public interface IMessage
- {
- string Key { get; }
- object[] GetArguments();
- string GetLocalizedMessage();
- string GetLocalizedMessage(CultureInfo locale);
- }
-}
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+
+// /// <summary>
+// /// Message Interface for a lazy loading.
+// /// For Native Language Support (NLS), system of software internationalization.
+// /// </summary>
+// public interface IMessage
+// {
+// string Key { get; }
+// object[] GetArguments();
+// string GetLocalizedMessage();
+// string GetLocalizedMessage(CultureInfo locale);
+// }
+//}
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
index cd4a191..9033630 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/MessageImpl.cs
@@ -1,81 +1,84 @@
-using Lucene.Net.Support;
-using System;
-using System.Globalization;
-using System.Text;
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+//using Lucene.Net.Support;
+//using System;
+//using System.Globalization;
+//using System.Text;
- /// <summary>
- /// Default implementation of Message interface.
- /// For Native Language Support (NLS), system of software internationalization.
- /// </summary>
-#if FEATURE_SERIALIZABLE
- [Serializable]
-#endif
- public class Message : IMessage
- {
- private readonly string key; // LUCENENET: marked readonly
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
- private readonly object[] arguments = Arrays.Empty<object>(); // LUCENENET: marked readonly
+// /// <summary>
+// /// Default implementation of Message interface.
+// /// For Native Language Support (NLS), system of software internationalization.
+// /// </summary>
+//#if FEATURE_SERIALIZABLE
+// [Serializable]
+//#endif
+// public class Message : IMessage
+// {
+// private readonly string key; // LUCENENET: marked readonly
- public Message(string key)
- {
- this.key = key;
+// private readonly object[] arguments = Arrays.Empty<object>(); // LUCENENET: marked readonly
- }
+// public Message(string key)
+// {
+// this.key = key;
- public Message(string key, params object[] args)
- : this(key)
- {
- this.arguments = args;
- }
+// }
- public virtual object[] GetArguments()
- {
- return (object[])this.arguments.Clone(); // LUCENENET specific: These are obviously not meant to be written to, so cloning the result
- }
+// public Message(string key, params object[] args)
+// : this(key)
+// {
+// this.arguments = args;
+// }
- public virtual string Key => this.key;
+// public virtual object[] GetArguments()
+// {
+// return (object[])this.arguments.Clone(); // LUCENENET specific: These are obviously not meant to be written to, so cloning the result
+// }
- public virtual string GetLocalizedMessage()
- {
- return GetLocalizedMessage(CultureInfo.CurrentUICulture);
- }
+// public virtual string Key => this.key;
- public virtual string GetLocalizedMessage(CultureInfo locale)
- {
- return NLS.GetLocalizedMessage(Key, locale, GetArguments());
- }
+// public virtual string GetLocalizedMessage()
+// {
+// return GetLocalizedMessage(CultureInfo.CurrentUICulture);
+// }
- public override string ToString()
- {
- object[] args = GetArguments();
- StringBuilder sb = new StringBuilder(Key);
- if (args != null)
- {
- for (int i = 0; i < args.Length; i++)
- {
- sb.Append(i == 0 ? " " : ", ").Append(args[i]);
- }
- }
- return sb.ToString();
- }
- }
-}
+// public virtual string GetLocalizedMessage(CultureInfo locale)
+// {
+// return NLS.GetLocalizedMessage(Key, locale, GetArguments());
+// }
+
+// public override string ToString()
+// {
+// object[] args = GetArguments();
+// StringBuilder sb = new StringBuilder(Key);
+// if (args != null)
+// {
+// for (int i = 0; i < args.Length; i++)
+// {
+// sb.Append(i == 0 ? " " : ", ").Append(args[i]);
+// }
+// }
+// return sb.ToString();
+// }
+// }
+//}
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
index 2bd901b..31b808d 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/NLS.cs
@@ -1,223 +1,226 @@
-using Lucene.Net.Support;
-using Lucene.Net.Util;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Reflection;
-using System.Resources;
-
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
- /// <summary>
- /// MessageBundles classes extend this class, to implement a bundle.
- ///
- /// For Native Language Support (NLS), system of software internationalization.
- ///
- /// This interface is similar to the NLS class in eclipse.osgi.util.NLS class -
- /// initializeMessages() method resets the values of all static strings, should
- /// only be called by classes that extend from NLS (see TestMessages.java for
- /// reference) - performs validation of all message in a bundle, at class load
- /// time - performs per message validation at runtime - see NLSTest.java for
- /// usage reference
- ///
- /// MessageBundle classes may subclass this type.
- /// </summary>
- public abstract class NLS // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
- {
- /// <summary>
- /// LUCENENET specific factory reference to inject instances of <see cref="ResourceManager"/>
- /// into this class.
- /// </summary>
- private static IResourceManagerFactory resourceManagerFactory = new BundleResourceManagerFactory();
- private static readonly IDictionary<string, Type> bundles = new Dictionary<string, Type>(0); // LUCENENET: marked readonly
-
- protected NLS()
- {
- // Do not instantiate
- }
-
- /// <summary>
- /// Gets the static <see cref="IResourceManagerFactory"/> instance responsible
- /// for creating <see cref="ResourceManager"/> instances in this class. LUCENENET specific.
- /// </summary>
- // LUCENENET NOTE: Don't make this into a property in case we need to make it into an extension method
- // in a centralized DI configuration builder.
- public static IResourceManagerFactory GetResourceManagerFactory()
- {
- return resourceManagerFactory;
- }
-
- /// <summary>
- /// Sets the <see cref="IResourceManagerFactory"/> used to create instances of <see cref="ResourceManager"/>
- /// for retrieving localized resources. Defaults to <see cref="BundleResourceManagerFactory"/> if not set. LUCENENET specific.
- /// </summary>
- /// <param name="resourceManagerFactory">The <see cref="IResourceManagerFactory"/> instance. Cannot be <c>null</c>.</param>
- // LUCENENET NOTE: Don't make this into a property in case we need to make it into an extension method
- // in a centralized DI configuration builder.
- public static void SetResourceManagerFactory(IResourceManagerFactory resourceManagerFactory)
- {
- NLS.resourceManagerFactory = resourceManagerFactory ?? throw new ArgumentNullException(nameof(resourceManagerFactory));
- }
-
- public static string GetLocalizedMessage(string key)
- {
- return GetLocalizedMessage(key, CultureInfo.InvariantCulture);
- }
-
- public static string GetLocalizedMessage(string key, CultureInfo locale)
- {
- string message = GetResourceBundleObject(key, locale);
- if (message == null)
- {
- return "Message with key:" + key + " and locale: " + locale
- + " not found.";
- }
- return message;
- }
-
- public static string GetLocalizedMessage(string key, CultureInfo locale,
- params object[] args)
- {
- string str = GetLocalizedMessage(key, locale);
-
- if (args.Length > 0)
- {
- str = string.Format(locale, str, args);
- }
-
- return str;
- }
-
- public static string GetLocalizedMessage(string key, params object[] args)
- {
- return GetLocalizedMessage(key, CultureInfo.CurrentUICulture, args);
- }
-
- /// <summary>
- /// Initialize a given class with the message bundle Keys Should be called from
- /// a class that extends NLS in a static block at class load time.
- /// </summary>
- /// <param name="bundleName">Property file with that contains the message bundle</param>
- /// <param name="clazz">where constants will reside</param>
- protected static void InitializeMessages(string bundleName, Type clazz)
- {
- try
- {
- Load(clazz);
- if (!bundles.ContainsKey(bundleName))
- bundles[bundleName] = clazz;
- }
- catch (Exception e) when (e.IsThrowable())
- {
- // ignore all errors and exceptions
- // because this function is supposed to be called at class load time.
- }
- }
-
- private static string GetResourceBundleObject(string messageKey, CultureInfo locale)
- {
- // slow resource checking
- // need to loop thru all registered resource bundles
- foreach(var key in bundles.Keys)
- {
- Type clazz = bundles[key];
- ResourceManager resourceBundle = resourceManagerFactory.Create(clazz);
- if (resourceBundle != null)
- {
- try
- {
- string obj = resourceBundle.GetString(messageKey, locale);
- if (obj != null)
- return obj;
- }
- catch (Exception e) when (e.IsMissingResourceException())
- {
- // just continue it might be on the next resource bundle
- }
- finally
- {
- resourceManagerFactory.Release(resourceBundle);
- }
- }
- }
- // if resource is not found
- return null;
- }
-
- private static void Load(Type clazz)
- {
- FieldInfo[] fieldArray = clazz.GetFields();
-
- // build a map of field names to Field objects
- int len = fieldArray.Length;
- IDictionary<string, FieldInfo> fields = new Dictionary<string, FieldInfo>(len * 2);
- for (int i = 0; i < len; i++)
- {
- fields[fieldArray[i].Name] = fieldArray[i];
- LoadFieldValue(fieldArray[i], clazz);
- }
- }
-
- private static void LoadFieldValue(FieldInfo field, Type clazz)
- {
- field.SetValue(null, field.Name);
- ValidateMessage(field.Name, clazz);
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="key">Message Key</param>
- /// <param name="clazz"></param>
- private static void ValidateMessage(string key, Type clazz)
- {
- // Test if the message is present in the resource bundle
- try
- {
- ResourceManager resourceBundle = resourceManagerFactory.Create(clazz);
- if (resourceBundle != null)
- {
- try
- {
- string obj = resourceBundle.GetString(key);
- //if (obj == null)
- // System.err.println("WARN: Message with key:" + key + " and locale: "
- // + Locale.getDefault() + " not found.");
- }
- finally
- {
- resourceManagerFactory.Release(resourceBundle);
- }
- }
- }
- catch (Exception e) when (e.IsMissingResourceException())
- {
- //System.err.println("WARN: Message with key:" + key + " and locale: "
- // + Locale.getDefault() + " not found.");
- }
- catch (Exception e) when (e.IsThrowable())
- {
- // ignore all other errors and exceptions
- // since this code is just a test to see if the message is present on the
- // system
- }
- }
- }
-}
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
+
+//using Lucene.Net.Support;
+//using Lucene.Net.Util;
+//using System;
+//using System.Collections.Generic;
+//using System.Globalization;
+//using System.Reflection;
+//using System.Resources;
+
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+
+// /// <summary>
+// /// MessageBundles classes extend this class, to implement a bundle.
+// ///
+// /// For Native Language Support (NLS), system of software internationalization.
+// ///
+// /// This interface is similar to the NLS class in eclipse.osgi.util.NLS class -
+// /// initializeMessages() method resets the values of all static strings, should
+// /// only be called by classes that extend from NLS (see TestMessages.java for
+// /// reference) - performs validation of all message in a bundle, at class load
+// /// time - performs per message validation at runtime - see NLSTest.java for
+// /// usage reference
+// ///
+// /// MessageBundle classes may subclass this type.
+// /// </summary>
+// public abstract class NLS // LUCENENET specific: CA1052 Static holder types should be Static or NotInheritable
+// {
+// /// <summary>
+// /// LUCENENET specific factory reference to inject instances of <see cref="ResourceManager"/>
+// /// into this class.
+// /// </summary>
+// private static IResourceManagerFactory resourceManagerFactory = new BundleResourceManagerFactory();
+// private static readonly IDictionary<string, Type> bundles = new Dictionary<string, Type>(0); // LUCENENET: marked readonly
+
+// protected NLS()
+// {
+// // Do not instantiate
+// }
+
+// /// <summary>
+// /// Gets the static <see cref="IResourceManagerFactory"/> instance responsible
+// /// for creating <see cref="ResourceManager"/> instances in this class. LUCENENET specific.
+// /// </summary>
+// // LUCENENET NOTE: Don't make this into a property in case we need to make it into an extension method
+// // in a centralized DI configuration builder.
+// public static IResourceManagerFactory GetResourceManagerFactory()
+// {
+// return resourceManagerFactory;
+// }
+
+// /// <summary>
+// /// Sets the <see cref="IResourceManagerFactory"/> used to create instances of <see cref="ResourceManager"/>
+// /// for retrieving localized resources. Defaults to <see cref="BundleResourceManagerFactory"/> if not set. LUCENENET specific.
+// /// </summary>
+// /// <param name="resourceManagerFactory">The <see cref="IResourceManagerFactory"/> instance. Cannot be <c>null</c>.</param>
+// // LUCENENET NOTE: Don't make this into a property in case we need to make it into an extension method
+// // in a centralized DI configuration builder.
+// public static void SetResourceManagerFactory(IResourceManagerFactory resourceManagerFactory)
+// {
+// NLS.resourceManagerFactory = resourceManagerFactory ?? throw new ArgumentNullException(nameof(resourceManagerFactory));
+// }
+
+// public static string GetLocalizedMessage(string key)
+// {
+// return GetLocalizedMessage(key, CultureInfo.InvariantCulture);
+// }
+
+// public static string GetLocalizedMessage(string key, CultureInfo locale)
+// {
+// string message = GetResourceBundleObject(key, locale);
+// if (message == null)
+// {
+// return "Message with key:" + key + " and locale: " + locale
+// + " not found.";
+// }
+// return message;
+// }
+
+// public static string GetLocalizedMessage(string key, CultureInfo locale,
+// params object[] args)
+// {
+// string str = GetLocalizedMessage(key, locale);
+
+// if (args.Length > 0)
+// {
+// str = string.Format(locale, str, args);
+// }
+
+// return str;
+// }
+
+// public static string GetLocalizedMessage(string key, params object[] args)
+// {
+// return GetLocalizedMessage(key, CultureInfo.CurrentUICulture, args);
+// }
+
+// /// <summary>
+// /// Initialize a given class with the message bundle Keys Should be called from
+// /// a class that extends NLS in a static block at class load time.
+// /// </summary>
+// /// <param name="bundleName">Property file with that contains the message bundle</param>
+// /// <param name="clazz">where constants will reside</param>
+// protected static void InitializeMessages(string bundleName, Type clazz)
+// {
+// try
+// {
+// Load(clazz);
+// if (!bundles.ContainsKey(bundleName))
+// bundles[bundleName] = clazz;
+// }
+// catch (Exception e) when (e.IsThrowable())
+// {
+// // ignore all errors and exceptions
+// // because this function is supposed to be called at class load time.
+// }
+// }
+
+// private static string GetResourceBundleObject(string messageKey, CultureInfo locale)
+// {
+// // slow resource checking
+// // need to loop thru all registered resource bundles
+// foreach(var key in bundles.Keys)
+// {
+// Type clazz = bundles[key];
+// ResourceManager resourceBundle = resourceManagerFactory.Create(clazz);
+// if (resourceBundle != null)
+// {
+// try
+// {
+// string obj = resourceBundle.GetString(messageKey, locale);
+// if (obj != null)
+// return obj;
+// }
+// catch (Exception e) when (e.IsMissingResourceException())
+// {
+// // just continue it might be on the next resource bundle
+// }
+// finally
+// {
+// resourceManagerFactory.Release(resourceBundle);
+// }
+// }
+// }
+// // if resource is not found
+// return null;
+// }
+
+// private static void Load(Type clazz)
+// {
+// FieldInfo[] fieldArray = clazz.GetFields();
+
+// // build a map of field names to Field objects
+// int len = fieldArray.Length;
+// IDictionary<string, FieldInfo> fields = new Dictionary<string, FieldInfo>(len * 2);
+// for (int i = 0; i < len; i++)
+// {
+// fields[fieldArray[i].Name] = fieldArray[i];
+// LoadFieldValue(fieldArray[i], clazz);
+// }
+// }
+
+// private static void LoadFieldValue(FieldInfo field, Type clazz)
+// {
+// field.SetValue(null, field.Name);
+// ValidateMessage(field.Name, clazz);
+// }
+
+// /// <summary>
+// ///
+// /// </summary>
+// /// <param name="key">Message Key</param>
+// /// <param name="clazz"></param>
+// private static void ValidateMessage(string key, Type clazz)
+// {
+// // Test if the message is present in the resource bundle
+// try
+// {
+// ResourceManager resourceBundle = resourceManagerFactory.Create(clazz);
+// if (resourceBundle != null)
+// {
+// try
+// {
+// string obj = resourceBundle.GetString(key);
+// //if (obj == null)
+// // System.err.println("WARN: Message with key:" + key + " and locale: "
+// // + Locale.getDefault() + " not found.");
+// }
+// finally
+// {
+// resourceManagerFactory.Release(resourceBundle);
+// }
+// }
+// }
+// catch (Exception e) when (e.IsMissingResourceException())
+// {
+// //System.err.println("WARN: Message with key:" + key + " and locale: "
+// // + Locale.getDefault() + " not found.");
+// }
+// catch (Exception e) when (e.IsThrowable())
+// {
+// // ignore all other errors and exceptions
+// // since this code is just a test to see if the message is present on the
+// // system
+// }
+// }
+// }
+//}
diff --git a/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs b/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
index 22c77df..154a1e1 100644
--- a/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
+++ b/src/Lucene.Net.QueryParser/Flexible/Messages/NLSException.cs
@@ -1,35 +1,38 @@
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
- /// <summary>
- /// Interface that exceptions should implement to support lazy loading of messages.
- ///
- /// For Native Language Support (NLS), system of software internationalization.
- ///
- /// This Interface should be implemented by all exceptions that require
- /// translation
- /// </summary>
- public interface INLSException
- {
- /// <summary>
- /// an instance of a class that implements the Message interface
- /// </summary>
- IMessage MessageObject { get; }
- }
-}
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
+
+// /// <summary>
+// /// Interface that exceptions should implement to support lazy loading of messages.
+// ///
+// /// For Native Language Support (NLS), system of software internationalization.
+// ///
+// /// This Interface should be implemented by all exceptions that require
+// /// translation
+// /// </summary>
+// public interface INLSException
+// {
+// /// <summary>
+// /// an instance of a class that implements the Message interface
+// /// </summary>
+// IMessage MessageObject { get; }
+// }
+//}
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/MessagesTestBundle.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/MessagesTestBundle.cs
index 748a60a..d27d761 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/MessagesTestBundle.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/MessagesTestBundle.cs
@@ -1,45 +1,48 @@
-using System;
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+//using System;
- public class MessagesTestBundle : NLS
- {
- private static readonly string BUNDLE_NAME = typeof(MessagesTestBundle).Name;
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
- private MessagesTestBundle()
- {
- // should never be instantiated
- }
+// public class MessagesTestBundle : NLS
+// {
+// private static readonly string BUNDLE_NAME = typeof(MessagesTestBundle).Name;
- static MessagesTestBundle()
- {
- // register all string ids with NLS class and initialize static string
- // values
- NLS.InitializeMessages(BUNDLE_NAME, typeof(MessagesTestBundle));
- }
+// private MessagesTestBundle()
+// {
+// // should never be instantiated
+// }
- // static string must match the strings in the property files.
- public static String Q0001E_INVALID_SYNTAX;
- public static String Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION;
+// static MessagesTestBundle()
+// {
+// // register all string ids with NLS class and initialize static string
+// // values
+// NLS.InitializeMessages(BUNDLE_NAME, typeof(MessagesTestBundle));
+// }
- // this message is missing from the properties file
- public static String Q0005E_MESSAGE_NOT_IN_BUNDLE;
- }
-}
+// // static string must match the strings in the property files.
+// public static String Q0001E_INVALID_SYNTAX;
+// public static String Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION;
+
+// // this message is missing from the properties file
+// public static String Q0005E_MESSAGE_NOT_IN_BUNDLE;
+// }
+//}
diff --git a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
index 2e31669..8f9bf46 100644
--- a/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Flexible/Messages/TestNLS.cs
@@ -1,129 +1,132 @@
-using Lucene.Net.Util;
-using NUnit.Framework;
-using System;
-using System.Globalization;
+// LUCENENET specific - Factored out NLS so end users can elect to use .NET localization or not
+// rather than forcing them to use it.
-namespace Lucene.Net.QueryParsers.Flexible.Messages
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (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.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+//using Lucene.Net.Util;
+//using NUnit.Framework;
+//using System;
+//using System.Globalization;
- public class TestNLS : LuceneTestCase
- {
- [Test]
- public void TestMessageLoading()
- {
- IMessage invalidSyntax = new Message(
- MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
- /*
- * if the default locale is ja, you get ja as a fallback:
- * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
- */
- if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja")))
- assertEquals("Syntax Error: XXX", invalidSyntax.GetLocalizedMessage(new CultureInfo("en")));
- }
+//namespace Lucene.Net.QueryParsers.Flexible.Messages
+//{
+// /*
+// * Licensed to the Apache Software Foundation (ASF) under one or more
+// * contributor license agreements. See the NOTICE file distributed with
+// * this work for additional information regarding copyright ownership.
+// * The ASF licenses this file to You under the Apache License, Version 2.0
+// * (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.apache.org/licenses/LICENSE-2.0
+// *
+// * Unless required by applicable law or agreed to in writing, software
+// * distributed under the License is distributed on an "AS IS" BASIS,
+// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// * See the License for the specific language governing permissions and
+// * limitations under the License.
+// */
- [Test]
- public void TestMessageLoading_ja()
- {
- IMessage invalidSyntax = new Message(
- MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
- assertEquals("構文エラー: XXX", invalidSyntax
- .GetLocalizedMessage(new CultureInfo("ja")));
- }
+// public class TestNLS : LuceneTestCase
+// {
+// [Test]
+// public void TestMessageLoading()
+// {
+// IMessage invalidSyntax = new Message(
+// MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
+// /*
+// * if the default locale is ja, you get ja as a fallback:
+// * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+// */
+// if (!CultureInfo.CurrentUICulture.Equals(new CultureInfo("ja")))
+// assertEquals("Syntax Error: XXX", invalidSyntax.GetLocalizedMessage(new CultureInfo("en")));
+// }
- [Test]
- public void TestNLSLoading()
- {
- String message = NLS
- .GetLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION, new CultureInfo("en"));
- /*
- * if the default locale is ja, you get ja as a fallback:
- * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
- */
- if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
- assertEquals("Truncated unicode escape sequence.", message);
+// [Test]
+// public void TestMessageLoading_ja()
+// {
+// IMessage invalidSyntax = new Message(
+// MessagesTestBundle.Q0001E_INVALID_SYNTAX, "XXX");
+// assertEquals("構文エラー: XXX", invalidSyntax
+// .GetLocalizedMessage(new CultureInfo("ja")));
+// }
- message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX, new CultureInfo("en"),
- "XXX");
- /*
- * if the default locale is ja, you get ja as a fallback:
- * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
- */
- if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
- assertEquals("Syntax Error: XXX", message);
- }
+// [Test]
+// public void TestNLSLoading()
+// {
+// String message = NLS
+// .GetLocalizedMessage(MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION, new CultureInfo("en"));
+// /*
+// * if the default locale is ja, you get ja as a fallback:
+// * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+// */
+// if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+// assertEquals("Truncated unicode escape sequence.", message);
- [Test]
- public void TestNLSLoading_ja()
- {
- String message = NLS.GetLocalizedMessage(
- MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
- new CultureInfo("ja-JP"));
- assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。", message);
+// message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX, new CultureInfo("en"),
+// "XXX");
+// /*
+// * if the default locale is ja, you get ja as a fallback:
+// * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+// */
+// if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+// assertEquals("Syntax Error: XXX", message);
+// }
- message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
- new CultureInfo("ja-JP"), "XXX");
- assertEquals("構文エラー: XXX", message);
- }
+// [Test]
+// public void TestNLSLoading_ja()
+// {
+// String message = NLS.GetLocalizedMessage(
+// MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
+// new CultureInfo("ja-JP"));
+// assertEquals("切り捨てられたユニコード・エスケープ・シーケンス。", message);
- [Test]
- public void TestNLSLoading_xx_XX()
- {
- try
- {
- CultureInfo locale = new CultureInfo("xx-XX");
- String message = NLS.GetLocalizedMessage(
- MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
- locale);
- /*
- * if the default locale is ja, you get ja as a fallback:
- * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
- */
- if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
- assertEquals("Truncated unicode escape sequence.", message);
+// message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
+// new CultureInfo("ja-JP"), "XXX");
+// assertEquals("構文エラー: XXX", message);
+// }
- message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
- locale, "XXX");
- /*
- * if the default locale is ja, you get ja as a fallback:
- * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
- */
- if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
- assertEquals("Syntax Error: XXX", message);
- }
- catch (CultureNotFoundException)
- {
- // ignore
+// [Test]
+// public void TestNLSLoading_xx_XX()
+// {
+// try
+// {
+// CultureInfo locale = new CultureInfo("xx-XX");
+// String message = NLS.GetLocalizedMessage(
+// MessagesTestBundle.Q0004E_INVALID_SYNTAX_ESCAPE_UNICODE_TRUNCATION,
+// locale);
+// /*
+// * if the default locale is ja, you get ja as a fallback:
+// * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+// */
+// if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+// assertEquals("Truncated unicode escape sequence.", message);
- // LUCENENET NOTE: .NET Core throws a CultureNotFoundException in this case.
- // There doesn't seem to be a reasonable way to test this as a result.
- }
- }
+// message = NLS.GetLocalizedMessage(MessagesTestBundle.Q0001E_INVALID_SYNTAX,
+// locale, "XXX");
+// /*
+// * if the default locale is ja, you get ja as a fallback:
+// * see ResourceBundle.html#getBundle(java.lang.String, java.util.Locale, java.lang.ClassLoader)
+// */
+// if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("ja", StringComparison.OrdinalIgnoreCase))
+// assertEquals("Syntax Error: XXX", message);
+// }
+// catch (CultureNotFoundException)
+// {
+// // ignore
- [Test]
- public void TestMissingMessage()
- {
- CultureInfo locale = new CultureInfo("en");
- String message = NLS.GetLocalizedMessage(
- MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);
+// // LUCENENET NOTE: .NET Core throws a CultureNotFoundException in this case.
+// // There doesn't seem to be a reasonable way to test this as a result.
+// }
+// }
- assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
- + locale.toString() + " not found.", message);
- }
- }
-}
+// [Test]
+// public void TestMissingMessage()
+// {
+// CultureInfo locale = new CultureInfo("en");
+// String message = NLS.GetLocalizedMessage(
+// MessagesTestBundle.Q0005E_MESSAGE_NOT_IN_BUNDLE, locale);
+
+// assertEquals("Message with key:Q0005E_MESSAGE_NOT_IN_BUNDLE and locale: "
+// + locale.toString() + " not found.", message);
+// }
+// }
+//}