From ca2e9c3ff44c5b90ac23f890141329c9b63dfec5 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Fri, 17 Mar 2023 17:51:52 -0500 Subject: [PATCH] CLDR-16389 v43 update analytics tags --- .../java/org/unicode/cldr/tool/Chart.java | 36 ++++++++----------- .../cldr/tool/FormattedFileWriter.java | 3 +- .../cldr/tool/GenerateChangeChart.java | 2 +- .../java/org/unicode/cldr/tool/ShowData.java | 1 + .../org/unicode/cldr/util/CldrUtility.java | 11 ++---- .../org/unicode/cldr/tool/analytics.html | 9 +++++ .../org/unicode/cldr/tool/chart-template.html | 31 +++++++--------- 7 files changed, 42 insertions(+), 51 deletions(-) create mode 100644 tools/cldr-code/src/main/resources/org/unicode/cldr/tool/analytics.html diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/Chart.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/Chart.java index aeac51bc0a2..786e9ba9e45 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/Chart.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/Chart.java @@ -133,34 +133,27 @@ public void writeContents(Writer pw, Factory factory) throws IOException { throw new IllegalArgumentException("Not implemented yet"); } - public void writeFooter(FormattedFileWriter pw) throws IOException { - standardFooter(pw, AnalyticsID.CLDR); + private static final class AnalyticsHelper { + private static final AnalyticsHelper INSTANCE = new AnalyticsHelper(); + + public final String str; + + AnalyticsHelper() { + str = ToolUtilities.getUTF8Data("analytics.html").lines().collect(Collectors.joining("\n")); + } } - private enum AnalyticsID { - CLDR("UA-7672775-1"), ICU("UA-7670213-1"), ICU_GUIDE("UA-7670256-1"), UNICODE("UA-7670213-1"), UNICODE_UTILITY("UA-8314904-1"); + public enum AnalyticsID { + CLDR("G-BPN1D3SEJM"), ICU("G-06PL1DM20S"), ICU_GUIDE("UA-7670256-1"), UNICODE("G-GC4HXC4GVQ"), UNICODE_UTILITY("G-0M7Q5QLZPV"); public final String id; private AnalyticsID(String id) { this.id = id; } - } - private static void standardFooter(FormattedFileWriter pw, AnalyticsID analytics) throws IOException { - pw.write("

\n" - + "\n" - + "Access to Copyright and terms of use" - + "\n" - + "
\n"); + public String getScript() { + return AnalyticsHelper.INSTANCE.str.replaceAll("TAG_ID", id); + } } public final void writeChart(Anchors anchors) { @@ -169,7 +162,6 @@ public final void writeChart(Anchors anchors) { x.setDirectory(getDirectory()); x.setShowDate(getShowDate()); writeContents(x); - writeFooter(x); } catch (IOException e) { throw new ICUUncheckedIOException(e); } @@ -190,7 +182,7 @@ public String getFixLinkFromPath(CLDRFile cldrFile, String path) { /** * Attempt to allocate the Chart that goes along with this report - * Also see {@link org.unicode.cldr.util.VoterReportStatus.ReportId} + * Also see {@link org.unicode.cldr.util.VoterReportStatus.ReportId} * and keep up to date */ public static Chart forReport(final ReportId report, final String locale) { diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/FormattedFileWriter.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/FormattedFileWriter.java index 9b4d0e682db..83c2b074418 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/FormattedFileWriter.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/FormattedFileWriter.java @@ -161,7 +161,8 @@ public void close() { "%title%", title, "%index%", indexLink, "%index-title%", indexTitle, - "%body%", contents }; + "%body%", contents, + "%analytics%", Chart.AnalyticsID.CLDR.getScript() }; writeTargetWithReplacements(dir, targetFileName, templateFileName, replacements); } diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/GenerateChangeChart.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/GenerateChangeChart.java index d4aaf9a2126..79c2ddb54d9 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/GenerateChangeChart.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/GenerateChangeChart.java @@ -341,7 +341,7 @@ public void close() throws IOException { out.write(""); PrintWriter pw2 = org.unicode.cldr.draft.FileUtilities.openUTF8Writer(dir, filename); String[] replacements = { "%header%", "", "%title%", title, "%version%", ToolConstants.CHART_DISPLAY_VERSION, - "%date%", CldrUtility.isoFormatDateOnly(new Date()), "%body%", out.toString() }; + "%date%", CldrUtility.isoFormatDateOnly(new Date()), "%body%", out.toString(), "%analytics%", Chart.AnalyticsID.CLDR.getScript() }; final String templateFileName = "chart-template.html"; FileUtilities.appendBufferedReader(ToolUtilities.getUTF8Data(templateFileName), pw2, replacements); pw2.close(); diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ShowData.java b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ShowData.java index d57d3f37959..09a69e81483 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ShowData.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/tool/ShowData.java @@ -707,6 +707,7 @@ static public void getChartTemplate(String title, String version, .add("%index%", "index.html") .add("%header%", header) .add("%version%", version) + .add("%analytics%", Chart.AnalyticsID.CLDR.getScript()) .add("%date%", showDate ? CldrUtility.isoFormatDateOnly(new Date()) : ""); if (indexTitle != null) { langTag diff --git a/tools/cldr-code/src/main/java/org/unicode/cldr/util/CldrUtility.java b/tools/cldr-code/src/main/java/org/unicode/cldr/util/CldrUtility.java index 2c340eaab6f..1dc81aad80b 100644 --- a/tools/cldr-code/src/main/java/org/unicode/cldr/util/CldrUtility.java +++ b/tools/cldr-code/src/main/java/org/unicode/cldr/util/CldrUtility.java @@ -48,6 +48,7 @@ import java.util.regex.Pattern; import org.unicode.cldr.draft.FileUtilities; +import org.unicode.cldr.tool.Chart; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableMap; @@ -176,15 +177,7 @@ public static String getPath(String path) { return getPath(path, null); } - public static final String ANALYTICS = "\n" - + ""; + public static final String ANALYTICS = Chart.AnalyticsID.CLDR.getScript(); public static final List MINIMUM_LANGUAGES = Arrays.asList(new String[] { "ar", "en", "de", "fr", "hi", "it", "es", "pt", "ru", "zh", "ja" }); // plus language itself diff --git a/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/analytics.html b/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/analytics.html new file mode 100644 index 00000000000..bf1d54e239e --- /dev/null +++ b/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/analytics.html @@ -0,0 +1,9 @@ + + + diff --git a/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/chart-template.html b/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/chart-template.html index d2bae0af0b8..72100ef6f17 100644 --- a/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/chart-template.html +++ b/tools/cldr-code/src/main/resources/org/unicode/cldr/tool/chart-template.html @@ -2,6 +2,7 @@ +%analytics% %title% %index-title% - - %body% - + +%body% + + +

+ + Access to Copyright and terms of use +
- - \ No newline at end of file + +