Welcome Guest, Not a member yet? Register   Sign In
Is it possible to translate the error views?
#1
Question 

Is it possible to translate the error views in app/Views/errors/html/* ?
Like app/Views/errors/html/error_404.php for example?
I tried to load a translated string with lang() but it's not working. It looks like at this point the Language class is not loaded because it only shows the key and not the actual translated text.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#2

I see:
Code:
Page Not Found
Controller or its method is not found: \App\Controllers\X::index

Code:
--- a/app/Views/errors/html/error_404.php
+++ b/app/Views/errors/html/error_404.php
@@ -70,7 +70,7 @@
</head>
<body>
    <div class="wrap">
-      <h1>404 - File Not Found</h1>
+      <h1><?= lang('HTTP.pageNotFound') ?></h1>

        <p>
            <?php if (! empty($message) && $message !== '(null)') : ?>
Reply
#3

That's weird. I tried that but with a custom language file and it didn't show the translated text, only the key name.
Now I just tried it on my other computer with the latest version of CI4 (4.1.9) and it works fine with HTTP.pageNotFound and with a custom message.
Maybe there's something wrong with my installation on the other computer. Or I'm on a different version of CI4...?
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#4

its work fine for me.

try check case sensitive
Reply




Theme © iAndrew 2016 - Forum software by © MyBB