In globalized software deployments, addressing users with appropriate grammatical gender is essential for respectful, accurate, and culturally competent communication. In many inflected languages—such as French, Spanish, German, Italian, Arabic, and Hindi—verbs, adjectives, and pronouns change form depending on the grammatical gender of the person being addressed. Historically, software developers had to implement custom in-app profile questionnaires and bespoke string replacement logic to handle grammatical gender, leading to inconsistent user experiences. Android 14 (API level 34) resolved this limitation by introducing the Grammatical Inflection Framework (GrammaticalInflectionManager). This framework enables users to declare their grammatical gender preference once at the system or per-app level, allowing applications to load gender-specific resource qualifiers automatically. Using the Android Debug Bridge (ADB), mobile developers and localization QA engineers can query dumpsys grammatical_inflection to inspect active gender preferences, audit resource loading, and test multilingual UI fidelity.
Understanding Android Grammatical Inflection Architecture
The Grammatical Inflection framework is integrated into Android’s core resource resolution pipeline. Key architectural concepts include:
- Grammatical Gender Constants: The API defines three formal grammatical gender values:
GRAMMATICAL_GENDER_NEUTRAL(Value:0): Indicates that the user has not specified a gender or prefers neutral/uninflected terms.GRAMMATICAL_GENDER_FEMININE(Value:1): Directs the resource loader to select feminine inflections.GRAMMATICAL_GENDER_MASCULINE(Value:2): Directs the resource loader to select masculine inflections.
- Resource Qualifier Matching: Android introduced the
grammatical-genderresource folder qualifier (e.g.values-fr-feminine/strings.xmlandvalues-fr-masculine/strings.xml). When a preference is declared, the asset manager matches strings against the active gender qualifier before falling back to default neutral strings. - Scope Hierarchy: Preferences can be set system-wide (applying to the operating system UI and all apps) or configured per-application through
GrammaticalInflectionManager.setRequestedApplicationGrammaticalGender(). - GrammaticalInflectionManagerService: Runs within the system server, persisting preferences across device reboots and broadcasting configuration update events (
onConfigurationChanged) to active applications when preferences change.
Prerequisites and ADB Environment Configuration
Auditing grammatical inflection requires a physical device or emulator running Android 14 (API level 34) or later. Ensure Developer Options and USB Debugging are active on your test target.
Confirm the device connection via the terminal:
adb devices -l
Verify that the grammatical_inflection service is registered with the Service Manager:
adb shell service check grammatical_inflection
The console confirms: Service grammatical_inflection: found.
Querying Complete Grammatical Inflection Service State
To inspect active gender preferences across all installed packages and user profiles, dump the service state via ADB:
adb shell dumpsys grammatical_inflection
The diagnostic dump provides a clear breakdown of system and per-package configurations:
GrammaticalInflectionManagerService:
User ID: 0
System-wide Grammatical Gender: 0 (NEUTRAL)
Package Preferences:
Package: com.example.socialapp
Gender: 1 (FEMININE)
Package: com.example.fitness
Gender: 2 (MASCULINE)
Package: com.android.settings
Gender: 0 (NEUTRAL)
This output allows QA teams to verify whether an application’s internal settings screen correctly synchronized its gender selection with the operating system.
Testing and Simulating Grammatical Gender via Command Line
Localization testers can use ADB command-line utilities to inject grammatical gender configurations dynamically without navigating multi-step account profile wizards.
To inspect the subcommands supported by the grammatical inflection service:
adb shell cmd grammatical_inflection help
To set the grammatical gender preference of a specific package to Feminine (value 1):
adb shell cmd grammatical_inflection set-app-gender com.example.socialapp --user 0 1
To set the grammatical gender preference to Masculine (value 2):
adb shell cmd grammatical_inflection set-app-gender com.example.socialapp --user 0 2
To reset the application preference back to the system neutral default (value 0):
adb shell cmd grammatical_inflection set-app-gender com.example.socialapp --user 0 0
Verify the committed change immediately in the dumpsys output:
adb shell dumpsys grammatical_inflection | grep -A 2 "com.example.socialapp"
Structuring Application Resources for Grammatical Gender
For applications to respond correctly to values set in dumpsys grammatical_inflection, project assets must follow the standard Android 14 resource directory structure.
In the application’s res/ directory, organize localized strings according to gender qualifiers:
res/
values-fr/
strings.xml <!-- Neutral fallback: "Bienvenue !" -->
values-fr-feminine/
strings.xml <!-- Feminine inflection: "Bienvenue, chère abonnée !" -->
values-fr-masculine/
strings.xml <!-- Masculine inflection: "Bienvenue, cher abonné !" -->
In application code, developers can query or update preferences programmatically:
GrammaticalInflectionManager manager = context.getSystemService(GrammaticalInflectionManager.class);
// Inspect the currently configured gender for this app
int currentGender = manager.getApplicationGrammaticalGender();
// Update the preference (triggers automated configuration reflow)
manager.setRequestedApplicationGrammaticalGender(Configuration.GRAMMATICAL_GENDER_FEMININE);
Troubleshooting Resource Inflation and Fallback Anomalies
When testing localized apps across grammatical gender variations, review these common debugging hurdles:
- Activity Restart vs Manual Handling: By default, changing grammatical gender triggers an activity recreation to reload resource bundles. If the application manifest declares
android:configChanges="grammaticalGender", the activity will not restart automatically; the application must overrideonConfigurationChanged()and manually refresh UI text views. - ICU MessageFormat Complex Strings: For sentences with multiple inflected terms or plural variations, combining grammatical gender with ICU
MessageFormatsyntax (usingselectblocks) inside a single string avoids sprawling XML resource files while maintaining grammatical precision:<string name="user_status">{gender, select, female{Elle est en ligne} male{Il est en ligne} other{En ligne}}</string> - Work Profile Isolation: Like per-app locales, grammatical gender configurations are scoped per user profile. When testing corporate enrolled profiles, always specify
--user 10during ADB test commands.
By auditing dumpsys grammatical_inflection with ADB, development teams guarantee respectful, natural, and grammatically accurate localization across international user communities.