title: How to set blank default locale for a flask app?
body: <p>I am working on a flask project (Python3). I have internationalization working fine in my project. This is the configuration method launched in the create_app factory:</p>
  <pre><code>def configure_languages(app):
  
      # flask-babel
      babel = Babel(app)
  
      @babel.localeselector
      def get_locale():
          languages = ['en', 'fr', 'de']
          lang = request.args.get('lang')
          if lang is None:
              return g.get('lang_code', app.config['BABEL_DEFAULT_LOCALE'])
          elif lang not in languages:
              return g.get('lang_code', app.config['BABEL_DEFAULT_LOCALE'])
          else:
              g.lang_code = lang
              return g.get('lang_code', app.config['BABEL_DEFAULT_LOCALE'])
  
      @app.before_request
      def ensure_lang_support():
          lang_code = g.get('lang_code', app.config['BABEL_DEFAULT_LOCALE'])
          if lang_code and lang_code not in app.config['SUPPORTED_LANGUAGES']:
              return abort(404)
  
  
      @app.url_defaults
      def set_language_code(endpoint, values):
          if 'lang_code' in values or not g.get('lang_code',
                                                app.config['BABEL_DEFAULT_LOCALE']):
              return
          if app.url_map.is_endpoint_expecting(endpoint, 'lang_code'):
              values['lang_code'] = g.get('lang_code',
                                            app.config['BABEL_DEFAULT_LOCALE'])
  
      @app.url_value_preprocessor
      def get_lang_code(endpoint, values):
          if values is not None:
              g.lang_code = values.pop('lang_code',
                                       app.config['BABEL_DEFAULT_LOCALE'])
  </code></pre>
  <p>This is how I define one of the blueprints:</p>
  <pre><code>frontend_blueprint = Blueprint('frontend', __name__, url_prefix='/&lt;lang_code&gt;')
  </code></pre>
  <p>The application is working fine. I can see the language codes in the url. For instance:</p>
  <pre><code>http://localhost:5000/en/posts
  http://localhost:5000/fr/posts
  http://localhost:5000/de/posts
  </code></pre>
  <p>The <code>en</code> is the default language in the config of my application.</p>
  <p>Nevertheless, I've got a question:</p>
  <p>How can I make the default language empty?</p>
  <p>I want my web app by default not to show any language code If I am using it in English:</p>
  <pre><code>http://localhost:5000/posts
  http://localhost:5000/about
  http://localhost:5000/help
  </code></pre>
  <p>Only when I select some particular language like French or German the url should become like these:</p>
  <pre><code>http://localhost:5000/fr/posts
  http://localhost:5000/fr/about
  http://localhost:5000/fr/help
  </code></pre>
  <p>Or</p>
  <pre><code>http://localhost:5000/de/posts
  http://localhost:5000/de/about
  http://localhost:5000/de/help
  </code></pre>
  <p>How can I do that? I tried to set the default language code in the config from 'en' to '' but obviously it's not working.</p>