Как изменить язык репозитория github

GitHub search allows filtering repositories by language. How can I set a repository to a specific language?

GitHub search allows filtering repositories by language. How can I set a repository to a specific language?

Peter Mortensen's user avatar

asked Nov 28, 2012 at 4:34

ohho's user avatar

1

You can also override certain files

$ cat .gitattributes
*.rb linguist-language=Java

Source

6

It is purely deduced from the code content.

As Pedro mentions:

Please note that we count the total bytes of each language’s file (we check the extension) to decide the percentages.
This means that if you see your project reported a JavaScript, but you swear you use Ruby, you probably have a JS lib somewhere that is bigger than your Ruby code

As detailed in «GitHub changes repository to the wrong language», you can add a .gitattributes file in which you can:

  • ignore part of your project (not considered for language detection)

      static/* linguist-vendored
    
  • consider part of your project as documentation:

      docs/* linguist-documentation
    
  • indicate some files with specific extension (for instance *.rb) should be considered a specific language:

      *.rb linguist-language=Java
    

Peter Mortensen's user avatar

answered Nov 28, 2012 at 7:14

VonC's user avatar

VonCVonC

1.2m508 gold badges4249 silver badges5070 bronze badges

2

You can also make some of the files vendor-ed. Just create a .gitattributes file in the main directory. If you want to exclude CSS from the language statistics write into the file something like this.
client/stylesheets/* linguist-vendored

This will hide all files in the client/stylesheets/ from the language statistics. In my case these are the .css files.

This solves your problem partly, because hides the most used language and choose the second one to be prime.

answered Apr 22, 2016 at 14:07

Kasmetski's user avatar

KasmetskiKasmetski

6876 silver badges10 bronze badges

0

A bit brute-force, but I used this .gitattributes file:

* linguist-vendored
*.js linguist-vendored=false

It says to ignore all files except .js, so JavaScript becomes the only possible language. My project, https://github.com/aim12340/jQuery-Before-Ready, was listed as HTML and this changed it to JavaScript.

Peter Mortensen's user avatar

answered Apr 20, 2017 at 13:19

EamonnM's user avatar

EamonnMEamonnM

2,1211 gold badge12 silver badges18 bronze badges

As VonC mentioned in the comments, you can put your libraries under «vendors» or «thirdparty» and the files won’t be analysed by linguist, the tool GitHub uses to analyse the language in your code.

# Vendored dependencies
- third[-_]?party/
- 3rd[-_]?party/
- vendors?/
- extern(al)?/

Later, they added more folder names.

Peter Mortensen's user avatar

answered Feb 24, 2014 at 13:47

Nicolas's user avatar

NicolasNicolas

1,12512 silver badges20 bronze badges

3

Create .gitattributes file in the root of your folder.
Suppose you want the language to be Java, just copy-paste

*.java linguist-detectable=true
*.js linguist-detectable=false
*.html linguist-detectable=false
*.xml linguist-detectable=false

in the .gitattributes file and push the file in the repository. Reload your GitHub page to see the language change.

For reference, use this GitHub repository.

insolor's user avatar

insolor

4049 silver badges16 bronze badges

answered Aug 15, 2019 at 4:03

Saif Siddiqui's user avatar

Saif SiddiquiSaif Siddiqui

7981 gold badge12 silver badges33 bronze badges

Rename the name of the code files in your repository with the extension added.

For example:

  • change abc to abc.py for Python
  • abc to abc.java for Java files
  • abc to abc.html for HTML

Peter Mortensen's user avatar

answered Nov 13, 2016 at 12:53

Lakshmana Deepesh's user avatar

1

GitHub search allows filtering repositories by language. How can I set a repository to a specific language?

Peter Mortensen's user avatar

asked Nov 28, 2012 at 4:34

ohho's user avatar

1

You can also override certain files

$ cat .gitattributes
*.rb linguist-language=Java

Source

6

It is purely deduced from the code content.

As Pedro mentions:

Please note that we count the total bytes of each language’s file (we check the extension) to decide the percentages.
This means that if you see your project reported a JavaScript, but you swear you use Ruby, you probably have a JS lib somewhere that is bigger than your Ruby code

As detailed in «GitHub changes repository to the wrong language», you can add a .gitattributes file in which you can:

  • ignore part of your project (not considered for language detection)

      static/* linguist-vendored
    
  • consider part of your project as documentation:

      docs/* linguist-documentation
    
  • indicate some files with specific extension (for instance *.rb) should be considered a specific language:

      *.rb linguist-language=Java
    

Peter Mortensen's user avatar

answered Nov 28, 2012 at 7:14

VonC's user avatar

VonCVonC

1.2m508 gold badges4249 silver badges5070 bronze badges

2

You can also make some of the files vendor-ed. Just create a .gitattributes file in the main directory. If you want to exclude CSS from the language statistics write into the file something like this.
client/stylesheets/* linguist-vendored

This will hide all files in the client/stylesheets/ from the language statistics. In my case these are the .css files.

This solves your problem partly, because hides the most used language and choose the second one to be prime.

answered Apr 22, 2016 at 14:07

Kasmetski's user avatar

KasmetskiKasmetski

6876 silver badges10 bronze badges

0

A bit brute-force, but I used this .gitattributes file:

* linguist-vendored
*.js linguist-vendored=false

It says to ignore all files except .js, so JavaScript becomes the only possible language. My project, https://github.com/aim12340/jQuery-Before-Ready, was listed as HTML and this changed it to JavaScript.

Peter Mortensen's user avatar

answered Apr 20, 2017 at 13:19

EamonnM's user avatar

EamonnMEamonnM

2,1211 gold badge12 silver badges18 bronze badges

As VonC mentioned in the comments, you can put your libraries under «vendors» or «thirdparty» and the files won’t be analysed by linguist, the tool GitHub uses to analyse the language in your code.

# Vendored dependencies
- third[-_]?party/
- 3rd[-_]?party/
- vendors?/
- extern(al)?/

Later, they added more folder names.

Peter Mortensen's user avatar

answered Feb 24, 2014 at 13:47

Nicolas's user avatar

NicolasNicolas

1,12512 silver badges20 bronze badges

3

Create .gitattributes file in the root of your folder.
Suppose you want the language to be Java, just copy-paste

*.java linguist-detectable=true
*.js linguist-detectable=false
*.html linguist-detectable=false
*.xml linguist-detectable=false

in the .gitattributes file and push the file in the repository. Reload your GitHub page to see the language change.

For reference, use this GitHub repository.

insolor's user avatar

insolor

4049 silver badges16 bronze badges

answered Aug 15, 2019 at 4:03

Saif Siddiqui's user avatar

Saif SiddiquiSaif Siddiqui

7981 gold badge12 silver badges33 bronze badges

Rename the name of the code files in your repository with the extension added.

For example:

  • change abc to abc.py for Python
  • abc to abc.java for Java files
  • abc to abc.html for HTML

Peter Mortensen's user avatar

answered Nov 13, 2016 at 12:53

Lakshmana Deepesh's user avatar

1

I know this isn’t a huge deal, but I like my GitHub to be linguistically diversified. I wrote a project in Swift and when I commit it says it’s in Objective-C.

I think it might be because the Parse frameworks are written in Objective-C and it detects that, but is there a way to change the display language on the main repository page?

Peter Mortensen's user avatar

asked Jan 11, 2016 at 3:26

Echizzle's user avatar

1

I found the simplest thing was to create a file called .gitattributes in the root folder of my repository, and give it these contents:

* linguist-vendored
*.js linguist-vendored=false

This example tells GitHub/Linguist to ignore all files, and then just look at .js files. My project, https://github.com/aim12340/jQuery-Before-Ready, was listed as HTML because the HTML example files were bigger than the JavaScript files. This file fixes it for me and now it’s listed as JavaScript.

Peter Mortensen's user avatar

answered Apr 20, 2017 at 13:16

EamonnM's user avatar

EamonnMEamonnM

2,1211 gold badge12 silver badges18 bronze badges

3

As mentioned in the GitHub help page

GitHub uses the open source Linguist library to determine file languages for syntax highlighting and repository statistics.
Some files are hard to identify, and sometimes projects contain more library and vendor files than their primary code.

So you need to check with github/linguist#troubleshooting in order to fix this situation.

The percentages are calculated based on the bytes of code for each language as reported by the List Languages API.
If the bar is reporting a language that you don’t expect:

  • Click on the name of the language in the stats bar to see a list of the files that are identified as that language.
  • If you see files that you didn’t write, consider moving the files into one of the paths for vendored code, or use the manual overrides feature to ignore them.
  • If the files are being misclassified, search for open issues to see if anyone else has already reported the issue. Any information you can add, especially links to public repositories, is helpful.
  • If there are no reported issues of this misclassification, open an issue and include a link to the repository or a sample of the code that is being misclassified.

Update February 2017 (one year later):

The article «How to Change Repo Language in GitHub» from Monica Powell

Upon researching how to resolve GitHub misclassifying the language of your projects I found out the solution is as simple as telling GitHub which files to ignore.

While you still want to commit these files to GitHub and therefore can’t use a .gitignore you can tell GitHub’s linguist which files to ignore in a .gitattributes file

static/* linguist-vendored

This one-line file told GitHub to ignore all of my files in my static/ folder which is where CSS and other assets are stored for a Flask app

The «Using .gitattributes» section does illustrate how to mark wrong languages.
For instance:

Checking code you didn’t write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project’s language stats and may even cause your project to be labeled as another language.
By default, Linguist treats all of the paths defined in vendor.yml as vendored and therefore doesn’t include them in the language statistics for a repository.

Use the linguist-vendored attribute to vendor or un-vendor paths.

$ cat .gitattributes
special-vendored-path/* linguist-vendored
jquery.js linguist-vendored=false

answered Jan 11, 2016 at 6:09

VonC's user avatar

VonCVonC

1.2m508 gold badges4249 silver badges5070 bronze badges

2

To make it simple, let me share my steps:

  1. Change directory to your project root folder;

  2. Create a file named .gitattributes using whatever tools of your choice:

     touch .gitattributes
    
  3. Edit the file by following the Linguist library instructions to tell GitHub how to do it, for example:

     vi .gitattributes
    

    Using linguist-vendored can let GitHub know to «skip» detection for this folder and sub-folders:

    src/main/resources/static/* linguist-vendored

    Use the linguist-documentation attribute to mark or unmark paths as documentation:

    project-docs/* linguist-documentation

    OR mark an individual file containing documentation

    documented_code.rb linguist-documentation=true

    This is a bit weird, but you can do also — to tell GitHub to treat some files with a specific extension (e.g., *.rb) as Java:

    *.rb linguist-language=Java

  4. Git add, commit and then push it to GitHub. The label will be corrected almost immediately.

Peter Mortensen's user avatar

answered Oct 12, 2016 at 3:06

Bright's user avatar

BrightBright

6365 silver badges9 bronze badges

1

Replace your .gitattributes with this, which reclassifies all files as Java.

 *.* linguist-language=Java

linguist

answered Feb 18, 2019 at 11:08

Sumit's user avatar

SumitSumit

98212 silver badges18 bronze badges

Create .gitattributes file in the root of your folder. Suppose you want the language to be Java, just copy-paste:

*.java linguist-detectable=true
*.js linguist-detectable=false
*.html linguist-detectable=false
*.xml linguist-detectable=false

in the .gitattributes file and push the file in the repo. Refresh your GitHub page to see the language change.

Note: So, for the desired language make it true and other’s false. It should work fine.

answered Aug 15, 2019 at 4:33

Saif Siddiqui's user avatar

Saif SiddiquiSaif Siddiqui

7981 gold badge12 silver badges33 bronze badges

I had a project that was started in Objective-C and changed to Swift completely (new project, but in the same repository directory).
GitHub kept identifying it as Objective-C no matter what I used in file .gitattributes (all solutions in previous answers).

So, if the jig is up, and you’re sure all the project is one language — you radically add:

# Direct Swift
*.* linguist-language=Swift

Only that fixed the problem :)

Peter Mortensen's user avatar

answered Dec 12, 2018 at 16:00

Ethan Halprin's user avatar

You can avoid unexpected languages detection (by filename extension, or by project subfolder, etc.) by using the GitHub linguist detectable option in your .gitattributes file:

Only programming languages are included in the language statistics. Languages of a different type (as defined in languages.yml) are not «detectable» causing them not to be included in the language statistics.

Use the linguist-detectable attribute to mark or unmark paths as detectable:

*.kicad_pcb linguist-detectable=true
*.sch linguist-detectable=true
tools/export_bom.py linguist-detectable=false

Peter Mortensen's user avatar

answered Feb 20, 2019 at 15:42

In the .gitattributes file just tell Linguist not to determine file languages which you don’t want.

Example for ignoring JavaScript files:

*.js linguist-vendored

Peter Mortensen's user avatar

answered Jan 25, 2019 at 11:01

Ramil Mammadov's user avatar

If you want to change the language of the Laravel repository, then add the following line to your .gitattributes file:

*.blade.php linguist-vendored

GitHub defines Blade files as HTML, but *.html linguist-vendored doesn’t work.

Peter Mortensen's user avatar

answered May 2, 2020 at 2:52

Slava's user avatar

SlavaSlava

1511 silver badge8 bronze badges

The answer is pretty simple:

just add these lines in your project terminal

  1. touch .gitattributes

    After writing this command, the file .gitattributes should be found in project explorer. If this file does not appear, try to show hidden files to find it.

  2. *.* linguist-language=Java

    Change Java with your target language -Swift in your case-

  3. git add .

  4. git commit -m "Change tagged language from Java to Kotlin"

  5. git push

Now after refreshing the GitHub page, you should found the new update.

Pranta Palit's user avatar

answered Feb 10, 2020 at 17:14

Mahmoud Zaher's user avatar

The solution which was provided by the expert EamonnM who answered this question above worked in my project, but there are two significant things.

  1. The language in the beginning of the second line of his code was the language you want instead of the language you dislike. Remember to distinguish it.

  2. It seems that you could not type any space before the *. (For example, I should type *.swift linguist-vendored=false when I want to change my language into Swift.)

Peter Mortensen's user avatar

answered Jul 21, 2018 at 14:58

Datoto's user avatar

I have problem with this also. I created .gitattributes in root of my project. I removed .js and .cs, but .html is still there. This is my .gitattributes file:

*.cs linguist-detectable=true
*.js linguist-detectable=false`
*.html linguist-detectable=false
*.xml linguist-detectable=false

When I add * linguist-vendored, I don’t see anything on GitHub.

Enter image description here

Answer:

It is still the same. .html is still shown.

Peter Mortensen's user avatar

answered Dec 13, 2019 at 11:54

Ivan Radunković's user avatar

1

  1. Create file «.gitattributes» in the root folder.

If you want your git to detect only .java files, you can use:

*.java linguist-detectable=true
*.* linguist-detectable=false

The . means every other file should not be detected as language.
For those who want more than 2 languages to be detected, they can manipulate this file.

ouflak's user avatar

ouflak

2,43810 gold badges43 silver badges49 bronze badges

answered Dec 11, 2021 at 16:33

Hamza Jashari's user avatar

1

Create a file named .gitattributes to your project root folder. Adding {file_name} linguist-generated=true can do the trick. In my case,

mvnw.cmd linguist-generated=true
mvnw linguist-generated=true

worked for me.

answered Jan 1, 2018 at 18:13

Jack's user avatar

JackJack

1551 silver badge10 bronze badges

Katherine Kelly

I recently organized my pinned repositories on GitHub and noticed that the language shown for one of my repositories didn’t quite seem right. It indicated HTML but I was expecting JavaScript because it was a vanilla JavaScript frontend and there were more lines of JavaScript code than HTML.

gif

To really set the scene, here’s a screenshot of my pinned repos with the incorrectly labeled repo (IMO) in question:
repo-html

I did some digging to figure out how GitHub determines the language for the repository as well as looking at how I can change the language shown.

GitHub and the Linguist Library

GitHub indicates it uses the open source Linguist Library to determine the file language for syntax highlighting and repository statistics.

Once you push changes to a repository on GitHub, the Linguist does its thing with a low-priority background job that will go through all of the files to determine the language of each file. Some things to note:

  • all of the languages it knows about are listed in languages.yml
  • excluded files include binary data, vendored code, generates code, documentation, files with either data (ie SQL) or prose (ie Markdown) languages, and explicit language overrides.

To determine the language for each remaining file, the Linguist employs the seven strategies listed below, done in the same order. Each step will either identify the exact language or will reduce the number of possible languages that get passed down to the next strategy.

  • Vim or Emacs modeline
  • commonly used filename
  • shell shebang
  • file extension
  • XML header
  • heuristics
  • naïve Bayesian classification

The results are then used to produce the language stats bar that shows the languages and its respective percentages that make up the repository. The percentage is determined by the bytes of code for each language as indicated by the List Languages API. The language shown for all of my pinned repos up top is the majority language.

Also, I was today years old when I found about the language stats bar. If you’re wondering where it is, it’s the colorful bar up at the top of your repository just under the commits/branches/etc. bar. Those colors indicate the languages that make up your repo, and click on it to get the full breakdown. 🤯

language stats bar

Changing the Repo Language Shown

Now that we know the background of how GitHub determines the repository language, I’ll show you how to change the language shown using gitattributes.

  1. Create a .gitattributes file in your repo at the top-level
  2. Edit the file and add the below line, subbing in the language(s) you want ignored denoted by its file extension before linguist-detectable=false. Since I want HTML ignored, I’ve included HTML below.

    *.html linguist-detectable=false
    
  3. Add, commit, and push the changes

And voila, the language is changed to JavaScript!

repo javascript

Resources
About Repository Languages
Linguist
How Do I Change the Category?

Русификация GitHub. Кто-нибудь пытался это сделать через Userscript?

Многим известен дикий фейл гитхаба по интернационализации.

Посему хочу узнать, есть ли в природе проект интернационализации web-интерфейса GitHub-а через Userscript?

1. Руссификация. 2. А зачем? Кому нужен этот русский язык?

2. А зачем? Кому нужен этот русский язык?

А термины типа stage, rebase, cherry pick тоже на русском? Я это в страшном кошмаре видел. и немного наяву, когда git gui у меня подцепил немецкую локаль. Сначала локализация, а потом что, именование бранчей на русском. или нет, транслитом? Нее, не нужно 🙂

Больше того скажу, если человек не знает английского, то и он в программировании не нужен.

2. А зачем? Кому нужен этот русский язык?

Т.е. русификация нужна кретинам?

Где-то полгода назад (а может и больше) на гитхабе вроде был какой-то русский интерфейс, а также там был опрос, нужна ли русификация интерфейса.

Я разумеется ответил «Нет» и включил английский.

Да я тоже фигею с любителей говностандартов, в данном случае — бритосский. Выбор, конечно, не велик, но зачем-то ведут себя как пользователи эппла.

поиск GitHub позволяет фильтровать репозитории по языку. Как установить репозиторий на определенный язык?

6 ответов

Как упоминалось в комментариях VonC, вы можете поместить свои библиотеки под «поставщиками» или «третьей стороной», и файлы не будут проанализированы лингвист, инструмент GitHub использует для анализа языка в вашем коде.

обновление: Они добавили больше имен папок

вы также можете переопределить определенные файлы

это чисто выводится из содержимого кода.

обратите внимание, что мы подсчитываем общее количество байтов файла каждого языка (мы проверяем расширение), чтобы решить проценты.
Это означает, что если вы видите, что ваш проект сообщил JavaScript, но вы клянетесь, что используете Ruby, у вас, вероятно, есть JS lib где-то больше, чем ваш Ruby code

как указано в «GitHub меняет репозиторий на неправильный язык», вы можете добавить .gitattributes файл, в котором вы можете:

игнорировать часть вашего проекта (не учитывается для определения языка)

считают частью проекта документации:

указать некоторые файлы с определенным расширением (например *.rb ) следует считать конкретным язык:

вы также можете сделать некоторые файлы vendor -ed. Просто создайте .gitattributes файл в главном каталоге. Если вы хотите исключить CSS из статистики язык записать в файл что-то вроде этого. client/stylesheets/* linguist-vendored

это скроет все файлы в client/stylesheets/ из статистики язык. В моем случае это .файл CSS.

это частично решает вашу проблему, потому что скрывает наиболее используемый язык и выбирает второй, чтобы быть простым.

немного грубой силы, но я использовал это .gitattributes file:

Он говорит, чтобы игнорировать все файлы, за исключением .js, поэтому JavaScript становится единственным возможным языком. Мой проект https://github.com/aim12340/jQuery-Before-Ready был указан как HTML, и это изменило его на JavaScript

переименуйте имя файлов кода в вашем репозитории с добавленным расширением.

GitHub in your language

Today, thanks to our great community, we’re turning on a number of languages that you can view GitHub in other than English.

You will now see links to these languages in the footer of each GitHub page. Just click on one of the languages to switch to it – it will store your language choice in your session. If your browser has the Accept-Language header set and you have not selected a language choice yet, we’ll prompt at the top of the page if you want us to switch to that language.

Not all of the site is translated, but hopefully most of the really important parts are and we’ll work on getting even more of it done in the near future.

Some of these translations are still a bit rough – if you want to comment on them or suggest improvements or sections of the site that should be translated next there is a Google Group here.

Понравилась статья? Поделить с друзьями:
  • Как изменить язык раскладки на ubuntu
  • Как изменить язык профиля пс4
  • Как изменить язык программ не поддерживающих юникод на windows 10
  • Как изменить язык приложения ютуб
  • Как изменить язык при установке windows 10