Bug 1047215 - [Gallery/Video]Background Overlays are not translated

This PR incorporates the patch from bug 1038984 as those changes to dialogs.js are required for this patch.
yes this function assumes the cases are mutually exclusive. The else-if version would be safer and clearer although they should not alter the behaviour of the function given the assumptions.

Thanks for the tip :)