CompactBundles library and build_defs.
This library aims to reduce time spent loading bundles at server startup. Design proposal at: []
GITHUB_BREAKING_CHANGES=none
@@ -40,10 +40,11 @@ import javax.annotation.Nullable;
*
*/
@Immutable
-final class RenderOnlySoyMsgBundleImpl extends SoyMsgBundle {
+public final class RenderOnlySoyMsgBundleImpl extends SoyMsgBundle {
/** The language/locale string of this bundle's messages. */
private final String localeString;
+
private final ULocale locale;
private final boolean isRtl;
@@ -118,6 +119,18 @@ final class RenderOnlySoyMsgBundleImpl extends SoyMsgBundle {
partRanges = partRangesBuilder.build();
}
+ /** Copies a RenderOnlySoyMsgBundleImpl, replacing only the localeString. */
+ public RenderOnlySoyMsgBundleImpl(
+ @Nullable String localeString, RenderOnlySoyMsgBundleImpl exemplar) {
+
+ this.localeString = localeString;
+ this.locale = localeString == null ? null : new ULocale(localeString);
+ this.isRtl = BidiGlobalDir.forStaticLocale(localeString) == BidiGlobalDir.RTL;
+ this.ids = exemplar.ids;
+ this.values = exemplar.values;
+ this.partRanges = exemplar.partRanges;
+ }
+
/** Brings a message back to life from only its ID and parts. */
// The constructor guarantees the type of ImmutableList.
private SoyMsg resurrectMsg(long id, ImmutableList<SoyMsgPart> parts) {
