Customizing GravityBoard translations

GravityBoard provides a simple way to customize translations using PHP filter hooks. This method allows you to override any translated text to better fit your specific use case.

This guide explains how to customize the text labels used throughout GravityBoard to better fit your specific use case. We'll use the example of changing "card" to "job" throughout the interface.

Where to Put Your Code

Before adding any custom code, you need to decide where to place it. There are two recommended approaches:

Option 1: Code Snippets Plugin (Recommended)

The safest way to add custom code is using the Code Snippets WordPress plugin. This method is recommended by GravityKit's documentation because:

  • Safer: If something goes wrong, you won't break your website
  • Theme-independent: Your customizations won't be lost when you update your theme
  • Easy to manage: You can easily enable/disable code snippets

After installing the Code Snippets plugin: 1. Go to Snippets > Add New in your WordPress admin 2. Give your snippet a descriptive title like "GravityBoard Custom Translations" 3. Paste your code in the editor (without <?php tags) 4. Set the snippet to run "Only run in Admin Area" or "Run Everywhere" as needed 5. Click Save Changes and Activate

Option 2: Theme's functions.php File

You can also add the code to your active theme's functions.php file:

  1. Go to Appearance > Theme Editor
  2. Click on Theme Functions (functions.php)
  3. Add your code at the end of the file (before any closing ?> tag if it exists)
  4. Click Update file

Important: Make sure not to include opening <?php tags if they already exist in the file. For more detailed instructions, see GravityKit's guide on where to put code samples.

Using PHP Translation Overrides

GravityBoard provides a filter hook that allows you to override any translated text. This is the easiest method and works for most use cases.

Basic Example: Changing "card" to "job"

Add this code to your theme's functions.php file or a custom plugin:

/**
 * Customize GravityBoard translations
 * Example: Change "card" to "job" throughout the interface
 */
function customize_gravityboard_translations( $translation_overrides, $feed_id ) {
    return array_merge( $translation_overrides, [
        // Replace "card" with "job" in various contexts
        'card' => ['job'],
        'Card' => ['Job'],
        'cards' => ['jobs'],
        'Cards' => ['Jobs'],
        'Card Title' => ['Job Title'],
        'Add a card' => ['Add a job'],
        'Move all cards in this lane' => [ 'Move all cards' ],
        'Search cards, assignees, labels, and more.' => [ 'Search jobs, assignees, labels, and more.' ],

        // Handle aria labels and accessibility text
        'Add card to %s' => ['Add job to %s'],
        'Cards in %s' => ['Jobs in %s'],
    ]);
}
add_filter( 'gk/gravityboard/translation-overrides', 'customize_gravityboard_translations', 10, 2 );

Advanced Example: Feed-Specific Translations

You can also customize translations for specific feeds:

function customize_gravityboard_translations_by_feed( $translation_overrides, $feed_id ) {
    // Different terminology for different feeds
    $custom_translations = [];

    switch( $feed_id ) {
        case 123: // HR Job Board
            $custom_translations = [
                'card' => ['job'],
                'Card' => ['Job'],
                'cards' => ['jobs'],
                'Cards' => ['Jobs'],
                'lane' => ['department'],
                'Lane' => ['Department'],
                'lanes' => ['departments'],
                'Lanes' => ['Departments'],
            ];
            break;

        case 456: // Project Management
            $custom_translations = [
                'card' => ['task'],
                'Card' => ['Task'],
                'cards' => ['tasks'],
                'Cards' => ['Tasks'],
                'lane' => ['project phase'],
                'Lane' => ['Project Phase'],
                'lanes' => ['project phases'],
                'Lanes' => ['Project Phases'],
            ];
            break;

        case 789: // Customer Support
            $custom_translations = [
                'card' => ['ticket'],
                'Card' => ['Ticket'],
                'cards' => ['tickets'],
                'Cards' => ['Tickets'],
                'lane' => ['status'],
                'Lane' => ['Status'],
                'lanes' => ['statuses'],
                'Lanes' => ['Statuses'],
            ];
            break;
    }

    return array_merge( $translation_overrides, $custom_translations );
}
add_filter( 'gk/gravityboard/translation-overrides', 'customize_gravityboard_translations_by_feed', 10, 2 );

Troubleshooting

Translations Not Appearing

  • Clear any caching plugins
  • Check that your hook is running (use error_log() to debug)
  • Verify the feed ID is correct when using feed-specific translations
  • Make sure that you are returning an array of translations, not a string
  • If using the Code Snippets plugin, ensure the snippet is activated and set to run in the correct context
  • If using functions.php, make sure you didn't accidentally include opening <?php tags

Partial Translations

  • Some strings might be generated dynamically - check the JavaScript console for untranslated text
  • Use browser developer tools to inspect the actual text being used

Performance Considerations

  • The translation override filter runs frequently, so keep your logic simple
  • Consider caching complex translation logic if needed

Complete Example: Job Board

Here's a complete example for converting GravityBoard into a job board interface:

function job_board_translations( $translation_overrides, $feed_id ) {
    return array_merge( $translation_overrides, [
        // Basic terms
        'card' => ['job'],
        'Card' => ['Job'],
        'cards' => ['jobs'],
        'Cards' => ['Jobs'],
        'lane' => ['department'],
        'Lane' => ['Department'],
        'lanes' => ['departments'],
        'Lanes' => ['Departments'],

        // Actions
        'Add card' => ['Post job'],
        'Add a card' => ['Post a job'],
        'Edit card' => ['Edit job'],
        'Delete card' => ['Remove job'],
        'Move card' => ['Move job'],
        'New Card' => ['New Job Posting'],

        // Messages
        'Are you sure you want to delete this card?' => ['Are you sure you want to remove this job posting?'],
        'Card "%s" updated successfully' => ['Job "%s" updated successfully'],
        'Card "%s" added successfully' => ['Job "%s" posted successfully'],

        // Interface elements
        'Add card to %s' => ['Post job to %s'],
        'Cards in %s' => ['Jobs in %s'],
        'Filter' => ['Filter Jobs'],
        'Keyword' => ['Job Title or Keywords'],
        'Enter a keyword…' => ['Search jobs…'],
        'Search cards, assignees, labels, and more.' => ['Search jobs, hiring managers, categories, and more.'],
    ]);
}
add_filter( 'gk/gravityboard/translation-overrides', 'job_board_translations', 10, 2 );

This will transform your GravityBoard from a generic card interface into a job board where users can "post jobs" to different "departments" instead of adding "cards" to "lanes".

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us