Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8338918: Remove non translated file name from WinResources resource bundle #21100

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 42 additions & 14 deletions src/jdk.jpackage/share/classes/jdk/jpackage/internal/I18N.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -24,36 +24,64 @@
*/
package jdk.jpackage.internal;

import java.util.ArrayList;
import java.util.List;
import java.util.ListResourceBundle;
import java.util.Map;
import jdk.internal.util.OperatingSystem;

import java.util.ResourceBundle;
import static java.util.stream.Collectors.toMap;
import java.util.stream.Stream;

class I18N {

static String getString(String key) {
if (PLATFORM.containsKey(key)) {
return PLATFORM.getString(key);
}
return SHARED.getString(key);
return BUNDLE.getString(key);
}

private static final ResourceBundle SHARED = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.MainResources");
private static class MultiResourceBundle extends ListResourceBundle {

MultiResourceBundle(ResourceBundle... bundles) {
contents = Stream.of(bundles).map(bundle -> {
return bundle.keySet().stream().map(key -> {
return Map.entry(key, bundle.getObject(key));
});
}).flatMap(x -> x).collect(toMap(Map.Entry::getKey, Map.Entry::getValue, (o, n) -> {
// Override old value with the new one
return n;
})).entrySet().stream().map(e -> {
return new Object[]{e.getKey(), e.getValue()};
}).toArray(Object[][]::new);
}

@Override
protected Object[][] getContents() {
return contents;
}

private final Object[][] contents;
}

private static final ResourceBundle PLATFORM;
private static final MultiResourceBundle BUNDLE;

static {
List<String> bundleNames = new ArrayList<>();

bundleNames.add("jdk.jpackage.internal.resources.MainResources");

if (OperatingSystem.isLinux()) {
PLATFORM = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.LinuxResources");
bundleNames.add("jdk.jpackage.internal.resources.LinuxResources");
} else if (OperatingSystem.isWindows()) {
PLATFORM = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.WinResources");
bundleNames.add("jdk.jpackage.internal.resources.WinResources");
bundleNames.add("jdk.jpackage.internal.resources.WinResourcesNoL10N");
} else if (OperatingSystem.isMacOS()) {
PLATFORM = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.MacResources");
bundleNames.add("jdk.jpackage.internal.resources.MacResources");
} else {
throw new IllegalStateException("Unknown platform");
}

BUNDLE = new MultiResourceBundle(bundleNames.stream().map(ResourceBundle::getBundle)
.toArray(ResourceBundle[]::new));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ resource.setup-icon=setup dialog icon
resource.post-app-image-script=script to run after application image is populated
resource.post-msi-script=script to run after msi file for exe installer is created
resource.wxl-file=WiX localization file
resource.wxl-file-name=MsiInstallerStrings_en.wxl
resource.main-wix-file=Main WiX project file
resource.overrides-wix-file=Overrides WiX project file
resource.shortcutpromptdlg-wix-file=Shortcut prompt dialog WiX project file
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#


resource.wxl-file-name=MsiInstallerStrings_en.wxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#


resource.wxl-file-name=MsiInstallerStrings_de.wxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#


resource.wxl-file-name=MsiInstallerStrings_ja.wxl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
#


resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ resource.setup-icon=Symbol für Dialogfeld "Setup"
resource.post-app-image-script=Auszuführendes Skript nach dem Auffüllen des Anwendungsimages
resource.post-msi-script=Auszuführendes Skript nach dem Erstellen der MSI-Datei für das EXE-Installationsprogramm
resource.wxl-file=WiX-Lokalisierungsdatei
resource.wxl-file-name=MsiInstallerStrings_de.wxl
resource.main-wix-file=Haupt-WiX-Projektdatei
resource.overrides-wix-file=Überschreibt WiX-Projektdatei
resource.shortcutpromptdlg-wix-file=Dialogfeld für Verknüpfungs-Prompt der WiX-Projektdatei
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ resource.setup-icon=設定ダイアログ・アイコン
resource.post-app-image-script=アプリケーション・イメージを移入した後に実行するスクリプト
resource.post-msi-script=exeインストーラのmsiファイルが作成された後に実行するスクリプト
resource.wxl-file=WiXローカリゼーション・ファイル
resource.wxl-file-name=MsiInstallerStrings_ja.wxl
resource.main-wix-file=メインWiXプロジェクト・ファイル
resource.overrides-wix-file=WiXプロジェクト・ファイルのオーバーライド
resource.shortcutpromptdlg-wix-file=ショートカット・プロンプト・ダイアログWiXプロジェクト・ファイル
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ resource.setup-icon=设置对话框图标
resource.post-app-image-script=要在填充应用程序映像之后运行的脚本
resource.post-msi-script=在为 exe 安装程序创建 msi 文件之后要运行的脚本
resource.wxl-file=WiX 本地化文件
resource.wxl-file-name=MsiInstallerStrings_zh_CN.wxl
resource.main-wix-file=主 WiX 项目文件
resource.overrides-wix-file=覆盖 WiX 项目文件
resource.shortcutpromptdlg-wix-file=快捷方式提示对话框 WiX 项目文件
Expand Down