= TranslatableString _(record)_
:Notice: 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.

== API

[source,java]
.TranslatableString.java
----
record TranslatableString {
  TranslatableString tr(String pattern, Object... paramArgs)     // <.>
  TranslatableString trn(String singularPattern, String pluralPattern, int number, Object... paramArgs)     // <.>
  String translate(TranslationService translationService, TranslationContext context)     // <.>
  String pattern()     // <.>
  boolean equals(Object o)
  int hashCode()
  String toString()
  String translated(String translatedText)
}
----

<.> xref:#tr_String_Object[tr(String, Object)]
+
--
A translatable string with a single pattern for both singular and plural forms.
--
<.> xref:#trn_String_String_int_Object[trn(String, String, int, Object)]
+
--
A translatable string with different patterns for singular and plural forms, selected automatically by the number
--
<.> xref:#translate_TranslationService_TranslationContext[translate(TranslationService, TranslationContext)]
+
--
Translates this string using the provided xref:refguide:applib:index/services/i18n/TranslationService.adoc[TranslationService] , selecting either the single or plural form as per _#pattern()_ .
--
<.> xref:#pattern_[pattern()]
+
--
The text to be translated; depends on whether _#isPluralForm()_ and whether to be translated.
--

== Members

[#tr_String_Object]
=== tr(String, Object)

A translatable string with a single pattern for both singular and plural forms.

[#trn_String_String_int_Object]
=== trn(String, String, int, Object)

A translatable string with different patterns for singular and plural forms, selected automatically by the number

[#translate_TranslationService_TranslationContext]
=== translate(TranslationService, TranslationContext)

Translates this string using the provided xref:refguide:applib:index/services/i18n/TranslationService.adoc[TranslationService] , selecting either the single or plural form as per _#pattern()_ .

[#pattern_]
=== pattern()

The text to be translated; depends on whether _#isPluralForm()_ and whether to be translated.

Any placeholders will _not_ have been replaced.

NB: this method is exposed only so that implementations of _org.apache.causeway.applib.exceptions.TranslatableException_ can return a non-null _Exception#getMessage() message_ when only a translatable message has been provided.
