Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Translations not appearing #2167

Open
eavonius opened this issue Jan 8, 2025 · 5 comments
Open

[Bug]: Translations not appearing #2167

eavonius opened this issue Jan 8, 2025 · 5 comments
Labels
bug Something isn't working

Comments

@eavonius
Copy link

eavonius commented Jan 8, 2025

What happened?

I'm missing translations when I view the table in version 3.5.10. Attached is a screenshot (I deleted the table rows for privacy).

Below is my config/livewire-tables.php file's contents:

<?php

return [
    /**
     * Options: tailwind | bootstrap-4 | bootstrap-5.
     */
    'theme' => 'tailwind',

    /**
     * Filter Frontend Asset Options
     */

    /**
     * Cache Rappasoft Frontend Assets
     */
    'cache_assets' => false,

    /**
     * Enable or Disable automatic injection of core assets
     */
    'inject_core_assets_enabled' => false,

    /**
     * Enable or Disable automatic injection of third-party assets
     */
    'inject_third_party_assets_enabled' => false,

    /**
     * Enable Blade Directives (Not required if automatically injecting or using bundler approaches)
     */
    'enable_blade_directives' => false,

    /**
     * Customise Script & Styles Paths
     */
    'script_base_path' => '/rappasoft/laravel-livewire-tables',

    /**
     * Filter Default Configuration Options
     *
     * */

    /**
     * Configuration options for DateFilter
     */
    'dateFilter' => [
        'defaultConfig' => [
            'format' => 'Y-m-d',
            'pillFormat' => 'd M Y', // Used to display in the Filter Pills
        ],
    ],

    /**
     * Configuration options for DateTimeFilter
     */
    'dateTimeFilter' => [
        'defaultConfig' => [
            'format' => 'Y-m-d\TH:i',
            'pillFormat' => 'd M Y - H:i', // Used to display in the Filter Pills
        ],
    ],

    /**
     * Configuration options for DateRangeFilter
     */
    'dateRange' => [
        'defaultOptions' => [],
        'defaultConfig' => [
            'allowInput' => true,   // Allow manual input of dates
            'altFormat' => 'F j, Y', // Date format that will be displayed once selected
            'ariaDateFormat' => 'F j, Y', // An aria-friendly date format
            'dateFormat' => 'Y-m-d', // Date format that will be received by the filter
            'earliestDate' => null, // The earliest acceptable date
            'latestDate' => null, // The latest acceptable date
            'locale' => 'en', // The default locale
        ],
    ],

    /**
     * Configuration options for NumberRangeFilter
     */
    'numberRange' => [
        'defaultOptions' => [
            'min' => 0, // The default start value
            'max' => 100, // The default end value
        ],
        'defaultConfig' => [
            'minRange' => 0, // The minimum possible value
            'maxRange' => 100, // The maximum possible value
            'suffix' => '', // A suffix to append to the values when displayed
            'prefix' => '', // A prefix to prepend to the values when displayed
        ],
    ],
    /**
     * Configuration options for SelectFilter
     */
    'selectFilter' => [
        'defaultOptions' => [],
        'defaultConfig' => [],
    ],
    /**
     * Configuration options for MultiSelectFilter
     */
    'multiSelectFilter' => [
        'defaultOptions' => [],
        'defaultConfig' => [],
    ],

    /**
     * Configuration options for MultiSelectDropdownFilter
     */
    'multiSelectDropdownFilter' => [
        'defaultOptions' => [],
        'defaultConfig' => [],
    ],

];

How to reproduce the bug

  1. Use the config settings and version I specified.
  2. Add the table to a page.
  3. Review the translation labels to see if they appear or not.

Missing translations

Package Version

3.5.10

PHP Version

None

Laravel Version

10.0

Alpine Version

No response

Theme

None

Notes

No response

Error Message

No response

@eavonius eavonius added the bug Something isn't working label Jan 8, 2025
@lrljoe
Copy link
Collaborator

lrljoe commented Jan 11, 2025

Have you previously published the views?

@lrljoe
Copy link
Collaborator

lrljoe commented Jan 11, 2025

Please also confirm which locale you're trying to use

@me-julian
Copy link
Contributor

Another dev on this codebase here.

Our app defaults to en_US.

When I initially wrote this table on the previous version of the package (3.4) I used App::setLocale('en'); to change it whenever we load the table's route since Laravel won't use a fallback ("en") if it's in a json file, according to my research then. Before updating to 3.5 that worked apart from a couple of pagination strings which we couldn't get working.

We haven't published any views. When I read the docs I was under the impression that's something you should avoid unless you need to customize them.

@eavonius
Copy link
Author

In this section of the documentation, it recommends not to publish views unless you want to customize this package, which we don't:

Customizing Views

@lrljoe
Copy link
Collaborator

lrljoe commented Jan 26, 2025

Both json and array translations are supported, there is a toggle to switch between them.

Can you confirm which locale(s) aren't working for you?

The default is array localisations, but you can switch to json by setting this in the config file:

'use_json_translations' => true,

It is default to false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants