Mac: Add microphone permissions string

Allows us to ask permission to use the microphone
This commit is contained in:
TellowKrinkle 2023-10-30 23:08:02 -05:00 committed by Connor McLaughlin
parent 7ec57692b1
commit 5c1f280988
5 changed files with 54 additions and 1 deletions

View File

@ -197,6 +197,36 @@ function(source_groups_from_vcxproj_filters file)
endforeach()
endfunction()
# Extracts a translation with the given type ("source" or "translation") from the given category of the given ts file
# (If there's multiple strings under the same category, which one it extracts is implementation defined. Just don't do it.)
function(extract_translation_from_ts file type category output)
file(READ "${file}" filecontent)
# Don't you love it when the best parser your language has to offer is regex?
set(regex_search "(<[^\\/>]+>[^<>]+<\\/[^>\\/]+>|<\\/?context>)")
set(regex_extract "<[^\\/>]+>([^<>]+)<\\/([^>\\/]+)>")
string(REGEX MATCHALL "${regex_search}" pieces "${filecontent}")
foreach(piece IN LISTS pieces)
if (piece STREQUAL "<context>")
set(found "")
set(name_match FALSE)
elseif (piece STREQUAL "</context>")
if (name_match)
set(${output} "${found}" PARENT_SCOPE)
break()
endif()
else()
string(REGEX REPLACE "${regex_extract}" "\\1" content "${piece}")
string(REGEX REPLACE "${regex_extract}" "\\2" tag "${piece}")
if (tag STREQUAL "name" AND content STREQUAL "${category}")
set(name_match TRUE)
endif()
if (tag STREQUAL "${type}")
set(found "${content}")
endif()
endif()
endforeach()
endfunction()
function(fixup_file_properties target)
get_target_property(SOURCES ${target} SOURCES)
if(APPLE)

View File

@ -221,6 +221,7 @@ elseif(APPLE)
set_source_files_properties(${QM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources/translations/)
endforeach()
copy_base_translations(pcsx2-qt)
extract_translation_from_ts(Translations/pcsx2-qt_en.ts source PermissionsDialogMicrophone PCSX2_MICROPHONE_USAGE_DESCRIPTION)
else()
qt_add_lrelease(pcsx2-qt TS_FILES ${TS_FILES} QM_FILES_OUTPUT_VARIABLE QM_FILES)
set(QM_OUTPUT_DIR "$<TARGET_FILE_DIR:pcsx2-qt>/translations")

View File

@ -48,6 +48,10 @@ QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU", "Show All")
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU", "Preferences...")
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU", "Quit %1")
QT_TRANSLATE_NOOP("MAC_APPLICATION_MENU", "About %1")
// Strings that will be parsed out by our build system and sent to fun places
QT_TRANSLATE_NOOP("PermissionsDialogMicrophone", "PCSX2 uses your microphone to emulate a USB microphone plugged into the virtual PS2")
QT_TRANSLATE_NOOP("PermissionsDialogCamera", "PCSX2 uses your camera to emulate an EyeToy camera plugged into the virtual PS2")
#endif
namespace QtHost

View File

@ -12616,7 +12616,7 @@ Right click to clear binding</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../Translations.cpp" line="253"/>
<location filename="../Translations.cpp" line="257"/>
<source>System Language [Default]</source>
<translation type="unfinished"></translation>
</message>
@ -14681,6 +14681,22 @@ Leaving the original controller type connected, but this may cause issues.</sour
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PermissionsDialogCamera</name>
<message>
<location filename="../Translations.cpp" line="54"/>
<source>PCSX2 uses your camera to emulate an EyeToy camera plugged into the virtual PS2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>PermissionsDialogMicrophone</name>
<message>
<location filename="../Translations.cpp" line="53"/>
<source>PCSX2 uses your microphone to emulate a USB microphone plugged into the virtual PS2</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>QObject</name>
<message>

View File

@ -39,6 +39,8 @@
<string>${CMAKE_OSX_DEPLOYMENT_TARGET}</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>NSMicrophoneUsageDescription</key>
<string>${PCSX2_MICROPHONE_USAGE_DESCRIPTION}</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.games</string>
<key>CFBundleDevelopmentRegion</key>