SAP / macOS-enterprise-privileges

For Mac users in enterprise environments, this application gives users control over the administration of their machine by elevating their level of access to administrator privileges on macOS. Users can set a timeframe in the application's settings to perform specific tasks, such as installing or removing an application.
Apache License 2.0
1.4k stars 149 forks source link

Issue with Handling ReasonPresetList Localizations for Multiple Languages (XML Configuration) #142

Closed qudly closed 3 hours ago

qudly commented 3 hours ago

Has anyone figured out how to handle the array of dictionaries for the ReasonPresetList? I am trying to build two presets based on language (or just one plus the default): one for en and another for fr.

Currently, my XML looks like this:

<key>ReasonPresetList</key>
<array>
    <dict>
        <key>en</key>
        <string>Just for fun (en)</string>
    </dict>
    <dict>
        <key>en</key>
        <string>For installing software (en)</string>
    </dict>
    <dict>
        <key>en</key>
        <string>Don't know (en)</string>
    </dict>
    <dict>
        <key>default</key>
        <string>Just for fun (default)</string>
    </dict>
    <dict>
        <key>default</key>
        <string>For installing software (default)</string>
    </dict>
    <dict>
        <key>default</key>
        <string>Don't know (default)</string>
    </dict>
    <dict>
        <key>fr</key>
        <string>Pour le fun (fr)</string>
    </dict>
    <dict>
        <key>fr</key>
        <string>Pour installer une application (fr)</string>
    </dict>
    <dict>
        <key>fr</key>
        <string>Je sais pas (fr)</string>
    </dict>
</array>

Here’s how I think it should work:

However, based on the behavior I’m observing during testing:

The documentation states:

A dictionary should contain these keys and values:

  • A key containing the locale identifier for each language (e.g., en or zh).
  • A value containing the localized reason string for that language.
  • An optional key default with a value containing the unlocalized reason string.

If no exact match is found, the default localization is used. If there is no default localization, the en localization is used. If there is no en localization, the dictionary is skipped.

From what I understand, the XML should allow Privileges to use one list or another based on the detected language. The default key is meant to act as a fallback. However, the observed behavior is inconsistent with the documentation, particularly for the fr locale.

Could someone confirm if the issue lies in my XML structure or if this is a bug with how ReasonPresetList is implemented? The documentation seems sparse, and I’m unable to determine the correct configuration for this scenario.

Any guidance or insights would be much Screenshot 2024-11-28 at 17 05 27 (1) Capture d’écran 2024-11-28 à 17 04 42 (1)

mthielemann commented 3 hours ago

@qudly The sample configuration profile in the app's Resources folder has an example of what you are trying to achieve. It says "A dictionary should contain … a key containing the locale identifier for each language". But this is not what you have done. You made one dictionary for each language. That should do the trick:

<key>ReasonPresetList</key>
<array>
    <dict>
        <key>en</key>
        <string>Just for fun (en)</string>
        <key>fr</key>
        <string>Pour le fun (fr)</string>
        <key>default</key>
        <string>Just for fun (default)</string>
    </dict>
    <dict>
        <key>en</key>
        <string>For installing software (en)</string>
        <key>fr</key>
        <string>Pour installer une application (fr)</string>
        <key>default</key>
        <string>For installing software (default)</string>
    </dict>
    <dict>
        <key>en</key>
        <string>Don't know (en)</string>
        <key>fr</key>
        <string>Je sais pas (fr)</string>
        <key>default</key>
        <string>Don't know (default)</string>
    </dict>
</array>

Hope this helps. I updated the documentation on the wiki with the example from the sample profile.