Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Issue with Locale api - translations.js 404

AoleeAolee Hobbyist & Coder ✭✭
edited June 2019 in Vanilla 2.0 - 2.8

Hi Guys,

Appreciate if you can help me on my issue, I tried to do a fresh 2.8 install. however i noticed there's a 404 on the api for translations.js

upon checking the api list from my dashboard, i don't seem to have the api endpoint for it (api for getting the translations.js)

I've crossed compare it with the vanilla documentation here =>

there's an extra api url for the .js file

May I know if there's anything i missed from the fresh install.

I actually don't need a translation as im using English for my forum. Is it possible or advisable to isable this api call (to retrieve the translations.js)

Some other infos that might be useful

a. /public_html/locales/ <empty>

b. inside the /conf folder, I only got these

c. I have this in my conf/config.php => $Configuration['Garden']['Locale'] = 'en';



  • R_JR_J Ex-Fanboy Munich Admin

    My guess is that you haven't enabled pretty urls

  • AoleeAolee Hobbyist & Coder ✭✭
    edited June 2019

    @R_J pretty url works fine by the way and


    gives us proper response

  • R_JR_J Ex-Fanboy Munich Admin

    Maybe your server tries to serve static files directly.

    But that translation.js is no static file: it is generated dynamically and as you see from the api result, there are translations like that included (just as a nexample):

    "BanReason.1":"Banned by a community manager."

    Without that translation the string "BanReason.1" would appear in your forum instead of the informative sentence.

  • R_JR_J Ex-Fanboy Munich Admin

    Sorry I just realized you wrote that:

    upon checking the api list from my dashboard, i don't seem to have the api endpoint for it (api for getting the translations.js)

    That's a problem. Please make sure that you have uploaded all files. Though this would be the easiest solution this is the most improbable...

  • R_JR_J Ex-Fanboy Munich Admin

    And another senseless post from me. You can use the endpoint, therefore the files should be there, forget what I wrote: nothing helpful by now :-(

  • R_JR_J Ex-Fanboy Munich Admin

    OMG! Seems like I do not read thoroughful and only babbling around today. In my installation there is only the above line for the locales api, too.

    Sorry for all this confusion, I will only post again if I have taken time to think of what I have written, promised 🤐

  • AoleeAolee Hobbyist & Coder ✭✭

    hehe it's ok thanks for replying to my post @R_J right now as a quick hack. i copied the content of the translations.js from vanilla site. and created directories and static file just to satisfy the request. I'll also try to dig it later.

  • charrondevcharrondev Developer Lead (PHP, JS) Montreal Vanilla Staff

    @SysCo This likely comes down to some server configuration issues.

    If you have a configured block in your server matching on certain files such as .json you will need to ensure it falls back to the PHP-FPM process.


    location ~* \.(?:ico|css|js|gif|jpe?g|png|svg|woff)$ {
      expires 7d;
      add_header Pragma public;
      add_header Cache-Control "public";
      try_files $uri @vanilla;
    # Default location handling
    location / {
      try_files $uri @vanilla;
    location @vanilla {
      fastcgi_param X_VANILLA 1;
      rewrite ^ /index.php$uri last;

    Notice the fallback in the first location's try_files directive.

  • AoleeAolee Hobbyist & Coder ✭✭

    hi @charrondev arg yeah you are right! Since the api url ended up with .js it went to that block. Many thanks it's working now!

  • I am also facing the same issue.

  • AoleeAolee Hobbyist & Coder ✭✭
    edited June 2019

    @juliatom543 as @charrondev mentioned. it's a webserver config side issue, handling the url re-write.

    Are you using NGINX ? or Apache?

    The one above example is for Nginx conf file, if you are using Apache ensure that your mod_rewrite is working in order to handle the url with .js extension.

  • I am experiencing the same issue on apache, but I'm sure url rewrite is working as it should... any idea? Thanks in advance.

  • AoleeAolee Hobbyist & Coder ✭✭

    we cant get a clue if we cant see your apache settings. appreciate if you can post here.

  • You are right, sorry.

    Vanilla Forum is installed in a subfolder (discuti/).

    Attached you can find my htaccess, and my virtual host.

    # Modified
    # If you modify this file then change the above line to: # Modified
    <IfModule mod_rewrite.c>
        RewriteEngine On
        # Redirect http to https
        RewriteCond %{HTTPS} off
        RewriteCond %{HTTP:X-Forwarded-Proto} !https
        RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]   
        # Certain hosts may require the following line.
        # If vanilla is in a subfolder then you need to specify it after the /.
        # (ex. You put Vanilla in /forum so change the next line to: RewriteBase /forum)
        RewriteBase /discuti/
        # Make sure that / doesn't try to go to index.php without a rewrite :)
        DirectoryIndex disabled
        # Deny access to certain directories that SHOULD NOT be exposed.
        RewriteRule (^|/)\.git - [L,R=403]
        RewriteRule ^cache/ - [L,R=403]
        RewriteRule ^cgi-bin/ - [L,R=403]
        RewriteRule ^uploads/import/ - [L,R=403]
        RewriteRule ^vendor/ - [L,R=403]
        # Prevent access to any php script by redirecting the request to /index.php
        # You can add an exception by adding another RewriteCond after this one.
        # Example: RewriteCond %{REQUEST_URI} !^/yourscriptname.php$
        # You can comment out this section if it causes you problems.
        # This is just a nice to have for security purposes.
        RewriteCond %{REQUEST_URI} !/index.php$
        RewriteRule (.+\.php) [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
        # Redirect any non existing file/directory to /index.php
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule (.*) index.php [E=X_REWRITE:1,E=X_PATH_INFO:/$1,L]
        # Add the proper X_REWRITE server variable for rewritten requests.
        RewriteCond %{ENV:REDIRECT_X_REWRITE} .+
        RewriteCond %{ENV:REDIRECT_X_PATH_INFO} (.+)
        RewriteRule ^index\.php - [E=X_REWRITE:1,E=!REDIRECT_X_REWRITE,E=X_PATH_INFO:%1,E=!REDIRECT_X_PATH_INFO,L]
    <IfModule mod_headers.c>
       <FilesMatch "(?<!embed)\.(css|js|woff|ttf|eot|svg|png|gif|jpeg|jpg|ico|swf)$">
          Header set Cache-Control "max-age=315360000"
          Header set Expires "31 December 2037 23:59:59 GMT"

    And here the virtual host

    <VirtualHost *:80>
        ServerName costellazione.loc
        Protocols  http/1.1
        CustomLog  "/var/log/apache-2.4/costellazione-access.log" combined
        ErrorLog   "/var/log/apache-2.4/costellazione-error.log"
        # Define the vhost to serve files
        DocumentRoot "/shared/httpd/costellazione/htdocs"
        <Directory "/shared/httpd/costellazione/htdocs">
            DirectoryIndex index.php index.html index.htm
            AllowOverride All
            Options All
            RewriteEngine on
            RewriteBase /
            Order allow,deny
            Allow from all
            Require all granted
        # In case for PHP-FPM 5.2 compatibility use 'GENERIC' instead of 'FPM'
        ProxyFCGIBackendType FPM
        # PHP-FPM Definition
        <FilesMatch \.php$>
            Require all granted
            SetHandler proxy:fcgi://php:9000
        <Proxy "fcgi://php:9000/">
            ProxySet timeout=180
            ProxySet connectiontimeout=180
        # If the php file doesn't exist, disable the proxy handler.
        # This will allow .htaccess rewrite rules to work and
        # the client will see the default 404 page of Apache
        RewriteCond %{REQUEST_FILENAME} \.php$
        RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_URI} !-f
        RewriteRule (.*) - [H=text/html]
        # Alias Definition
        Alias "/devilbox-api/" "/var/www/default/api/devilbox-api/"
        <Location "/devilbox-api/">
            # Allow cross domain request from these hosts
            SetEnvIf Origin "http(s)?://(.*)$" AccessControlAllowOrigin=$0
            Header add Access-Control-Allow-Origin %{AccessControlAllowOrigin}e env=AccessControlAllowOrigin
            Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
            Header always set Access-Control-Max-Age "0"
            Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
            # Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
            RewriteEngine On
            RewriteCond %{REQUEST_METHOD} OPTIONS
            RewriteRule ^(.*)$ $1 [R=200,L]
        <Directory "/var/www/default/api/devilbox-api/">
            Order allow,deny
            Allow from all
            Require all granted
        # Deny Definition
        <FilesMatch "/\.git">
            Order allow,deny
            Deny from all
        # Deny Definition
        <FilesMatch "/\.ht.*">
            Order allow,deny
            Deny from all
        # Custom directives

    The problem is actually bigger than I thought:

    I just tried migrating from 2.3.1 to 3.2, following all instructions on how to upgrade, and the frontend works as intended, while all api calls are not working.

    Thanks in advance!

  • edited November 2019

    @Aolee any suggestions? Thanks!

  • AoleeAolee Hobbyist & Coder ✭✭

    Hi @masioramaweb sorry for the late reply. base on the error under the developer tool it looks not only translations.js but other JS as well. I haven't tried using a sub folder yet. but seems to be missing configuration for handling .js

  • Here is I being rather obvious. Are those files really existing in said location? If so, check their folder/file permission.

    I join this thread because today I tried to get rid of those files altogether since the forum does not seem to even use them. I deleted the folder, but the call to the scripts seems hardcoded ... some webpack stuff

  • Hello @Aolee and @donshakespeare, thanks for your hints.

    Indeed the files are not present in the directory dist, and it is completely empty (because I'm in Dev mode?).

    Should I try to change environment (some variable in config.php maybe) and see what happens?

    I have no idea how to exclude those files from webpack compilation if they are indeed not necessary... 😕

  • I believe the file that is culprit is \vanilla-3.2\library\Vanilla\Web\Asset\WebpackAssetProvider.php

    It adds files not using the familiar addJSFile code. It is hard for me to intercept.

    So in my emergency use case, in the function below I have returned an empty array. For now, this hack provides good riddance.

    public function getScripts(string $section): array {
     return [];
  • There is a huge caveat, entry points from Swagger API need those files ....

Sign In or Register to comment.