'Include hash in translation JSON asset file name

I store my translation files as JSON in /src/assets/i18n. In order to bust cache, I want to fingerprint / include hash to the filename and use the hashed file named when I retrieve the file over HTTP. How do I accomplish this in Angular?



Solution 1:[1]

Going with the last method mentioned here as it's the most efficient. Thanks Netanel.

Solution 2:[2]

You should store the return value of the random.Next() method into a variable. (The problem is that you try to cast/convert the class instance to an int.)

using System;
                    
public class Program
{
    public static void Main()
    {
        int u=0;
        
        char[] vs = new char[] { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '~', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '+', '=', '|', ':', };
        string strng = null;

        Console.WriteLine(vs.Length);
        // just create an instance of the Random class once.
        Random random = new Random();

        while (u <= 10)
        {
            // store the random value into rndm (it's already an int)
            var rndm = random.Next(0, vs.Length);
            strng = strng + vs[rndm];
            u++;
        }
        Console.WriteLine(strng);
    }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 karthikaruna
Solution 2