Skip to content

Commit

Permalink
fix i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
yofukashino committed Nov 5, 2024
1 parent 45db2aa commit 5230511
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 34 deletions.
5 changes: 3 additions & 2 deletions src/Components/HDRCaptureSwitch.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CheckboxItem, Flex } from "replugged/components";
import { Checkbox, CheckboxItem, Flex } from "replugged/components";
import { SettingValues } from "../index";
import { defaultSettings } from "../lib/consts";
import Utils from "../lib/utils";
Expand All @@ -9,7 +9,8 @@ export default (): React.ReactElement => (
paddingLeft: "16px",
}}>
<CheckboxItem
{...Utils.useSetting(SettingValues, "hdrCaptureMode", defaultSettings.hdrCaptureMode)}>
{...Utils.useSetting(SettingValues, "hdrCaptureMode", defaultSettings.hdrCaptureMode)}
type={Checkbox.Types.INVERTED}>
HDR Capture Mode
</CheckboxItem>
</Flex>
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ export const stop = (): void => {
PluginInjector.uninjectAll();
Injections.removeInjections();
};
export { defaultSettings } from "./lib/consts";
export { defaultSettings, streamStoreKeys } from "./lib/consts";
export { Settings } from "./Components/Settings";
10 changes: 3 additions & 7 deletions src/injections/StreamSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ export default async (): Promise<void> => {
StreamSettings,
loader,
([{ selectedSource }], res: React.ReactElement & Types.Tree) => {
console.log(res);
const SourceContainer = Utils.findInReactTree(res, (c: React.ReactElement & Types.Tree) =>
c?.props?.children?.some((v) =>
v?.type?.toString()?.includes(".Messages.GO_LIVE_MODAL_ENABLE_SCREEN_SOUNDSHARE_LABEL"),
),
c?.props?.children?.some((v) => v?.type?.toString()?.includes('.id.startsWith("screen")')),
) as React.ReactElement & Types.Tree;
if (SourceContainer?.props)
SourceContainer.props.children = SourceContainer.props.children.filter(
(v) =>
!v?.type
?.toString()
?.includes(".Messages.GO_LIVE_MODAL_ENABLE_SCREEN_SOUNDSHARE_LABEL"),
(v) => !v?.type?.toString()?.includes("screen:"),
);
const qualitySelectorElement = res.props.children.find((c) => Boolean(c?.props?.onFPSChange));
if (qualitySelectorElement?.props)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/requiredModules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Modules.loadModules = async (): Promise<void> => {
.then(({ exports }) => exports);
Modules.StreamSettingsPromise = webpack
.waitForModule<Types.GenericExport>(
webpack.filters.bySource("Messages.GO_LIVE_MODAL_APPLICATION_FORM_TITLE"),
webpack.filters.bySource(".NOTIFY_STREAM_SETTING_UPDATE,"),
{
raw: true,
},
Expand Down
41 changes: 18 additions & 23 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ export const saveModuleKeys = (): Promise<void> => {
).find(
([_key, value]) =>
Array.isArray(value) &&
value.some(
(button: Types.StreamButtons) =>
button.label ==
i18n.Messages.STREAM_FPS_OPTION.format({
value: 15,
}),
),
value.some((button: Types.StreamButtons) => button.label != 15 && button.value == 15),
)[0];

streamStoreKeys.ApplicationStreamPresetValues = Object.entries(
Expand All @@ -58,13 +52,7 @@ export const saveModuleKeys = (): Promise<void> => {
).find(
([_key, value]) =>
Array.isArray(value) &&
value.some(
(button: Types.StreamButtons) =>
button.label ==
i18n.Messages.SCREENSHARE_RESOLUTION_ABBREVIATED.format({
resolution: 720,
}),
),
value.some((button: Types.StreamButtons) => button.label != 720 && button.value == 720),
)[0];

streamStoreKeys.ApplicationStreamResolutions = Object.entries(
Expand Down Expand Up @@ -97,7 +85,7 @@ export const saveModuleKeys = (): Promise<void> => {
);
streamStoreKeys.makeResolutionLabel = webpack.getFunctionKeyBySource(
Modules.ApplicationStreamingOption,
"Messages.SCREENSHARE_RESOLUTION_ABBREVIATED",
"Messages.",
);
return Promise.resolve();
};
Expand Down Expand Up @@ -174,9 +162,9 @@ export const setCustomParameters = (streamingConstants: Types.StreamingConstants
})),
ApplicationStreamFPSButtonsWithSuffixLabel: streamingConstants.fps.map((fps) => ({
value: fps,
label: i18n.Messages.STREAM_FPS_OPTION.format({
value: fps,
}),
label: defaultParameters.ApplicationStreamFPSButtonsWithSuffixLabel.find(
(button) => button.value == 15,
).label.replace("15", `${fps}`),
})),
ApplicationStreamPresetValues: {
1: [
Expand All @@ -201,17 +189,24 @@ export const setCustomParameters = (streamingConstants: Types.StreamingConstants
},
ApplicationStreamResolutionButtons: streamingConstants.resolution.map((resolution) => ({
value: resolution,
label: resolution == 0 ? i18n.Messages.SCREENSHARE_SOURCE : resolution,
label:
resolution == 0
? defaultParameters.ApplicationStreamResolutionButtonsWithSuffixLabel.find(
(button) => button.value == 0,
).label
: resolution,
})),
ApplicationStreamResolutionButtonsWithSuffixLabel: streamingConstants.resolution.map(
(resolution) => ({
value: resolution,
label:
resolution == 0
? i18n.Messages.SCREENSHARE_SOURCE
: i18n.Messages.SCREENSHARE_RESOLUTION_ABBREVIATED.format({
resolution,
}),
? defaultParameters.ApplicationStreamResolutionButtonsWithSuffixLabel.find(
(button) => button.value == 0,
).label
: defaultParameters.ApplicationStreamResolutionButtonsWithSuffixLabel.find(
(button) => button.value == 720,
).label.replace("720", `${resolution}`),
}),
),
ApplicationStreamResolutions: Object.assign(
Expand Down

0 comments on commit 5230511

Please sign in to comment.